mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	refactor: feature oriented architecture for project-environment (#5510)
This commit is contained in:
		
							parent
							
								
									63f6af06da
								
							
						
					
					
						commit
						26f9cf98d5
					
				@ -20,7 +20,7 @@ import { ResetTokenStore } from './reset-token-store';
 | 
				
			|||||||
import UserFeedbackStore from './user-feedback-store';
 | 
					import UserFeedbackStore from './user-feedback-store';
 | 
				
			||||||
import FeatureStrategyStore from '../features/feature-toggle/feature-toggle-strategies-store';
 | 
					import FeatureStrategyStore from '../features/feature-toggle/feature-toggle-strategies-store';
 | 
				
			||||||
import FeatureToggleClientStore from '../features/client-feature-toggles/client-feature-toggle-store';
 | 
					import FeatureToggleClientStore from '../features/client-feature-toggles/client-feature-toggle-store';
 | 
				
			||||||
import EnvironmentStore from './environment-store';
 | 
					import EnvironmentStore from '../features/project-environments/environment-store';
 | 
				
			||||||
import FeatureTagStore from './feature-tag-store';
 | 
					import FeatureTagStore from './feature-tag-store';
 | 
				
			||||||
import { FeatureEnvironmentStore } from './feature-environment-store';
 | 
					import { FeatureEnvironmentStore } from './feature-environment-store';
 | 
				
			||||||
import { ClientMetricsStoreV2 } from './client-metrics-store-v2';
 | 
					import { ClientMetricsStoreV2 } from './client-metrics-store-v2';
 | 
				
			||||||
 | 
				
			|||||||
@ -3,14 +3,14 @@ import EventStore from '../../db/event-store';
 | 
				
			|||||||
import GroupStore from '../../db/group-store';
 | 
					import GroupStore from '../../db/group-store';
 | 
				
			||||||
import { AccountStore } from '../../db/account-store';
 | 
					import { AccountStore } from '../../db/account-store';
 | 
				
			||||||
import RoleStore from '../../db/role-store';
 | 
					import RoleStore from '../../db/role-store';
 | 
				
			||||||
import EnvironmentStore from '../../db/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, EventService, 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 '../../../test/fixtures/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 FeatureTagStore from '../../db/feature-tag-store';
 | 
					import FeatureTagStore from '../../db/feature-tag-store';
 | 
				
			||||||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
 | 
					import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@ import GroupStore from '../../db/group-store';
 | 
				
			|||||||
import { AccountStore } from '../../db/account-store';
 | 
					import { AccountStore } from '../../db/account-store';
 | 
				
			||||||
import { AccessStore } from '../../db/access-store';
 | 
					import { AccessStore } from '../../db/access-store';
 | 
				
			||||||
import RoleStore from '../../db/role-store';
 | 
					import RoleStore from '../../db/role-store';
 | 
				
			||||||
import EnvironmentStore from '../../db/environment-store';
 | 
					import EnvironmentStore from '../project-environments/environment-store';
 | 
				
			||||||
import { Db } from '../../db/db';
 | 
					import { Db } from '../../db/db';
 | 
				
			||||||
import { IUnleashConfig } from '../../types';
 | 
					import { IUnleashConfig } from '../../types';
 | 
				
			||||||
import FakeEventStore from '../../../test/fixtures/fake-event-store';
 | 
					import FakeEventStore from '../../../test/fixtures/fake-event-store';
 | 
				
			||||||
@ -28,7 +28,7 @@ import FakeGroupStore from '../../../test/fixtures/fake-group-store';
 | 
				
			|||||||
import { FakeAccountStore } from '../../../test/fixtures/fake-account-store';
 | 
					import { FakeAccountStore } from '../../../test/fixtures/fake-account-store';
 | 
				
			||||||
import FakeAccessStore from '../../../test/fixtures/fake-access-store';
 | 
					import FakeAccessStore from '../../../test/fixtures/fake-access-store';
 | 
				
			||||||
import FakeRoleStore from '../../../test/fixtures/fake-role-store';
 | 
					import FakeRoleStore from '../../../test/fixtures/fake-role-store';
 | 
				
			||||||
import FakeEnvironmentStore from '../../../test/fixtures/fake-environment-store';
 | 
					import FakeEnvironmentStore from '../project-environments/fake-environment-store';
 | 
				
			||||||
import EventStore from '../../db/event-store';
 | 
					import EventStore from '../../db/event-store';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    createChangeRequestAccessReadModel,
 | 
					    createChangeRequestAccessReadModel,
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ import {
 | 
				
			|||||||
    IVariant,
 | 
					    IVariant,
 | 
				
			||||||
    SKIP_CHANGE_REQUEST,
 | 
					    SKIP_CHANGE_REQUEST,
 | 
				
			||||||
} from '../../../types';
 | 
					} from '../../../types';
 | 
				
			||||||
import EnvironmentService from '../../../services/environment-service';
 | 
					import EnvironmentService from '../../project-environments/environment-service';
 | 
				
			||||||
import { ForbiddenError, PatternError, PermissionError } from '../../../error';
 | 
					import { ForbiddenError, PatternError, PermissionError } from '../../../error';
 | 
				
			||||||
import { ISegmentService } from '../../../segments/segment-service-interface';
 | 
					import { ISegmentService } from '../../../segments/segment-service-interface';
 | 
				
			||||||
import { createFeatureToggleService, createSegmentService } from '../..';
 | 
					import { createFeatureToggleService, createSegmentService } from '../..';
 | 
				
			||||||
 | 
				
			|||||||
@ -6,3 +6,4 @@ export * from './change-request-access-service/createChangeRequestAccessReadMode
 | 
				
			|||||||
export * from './segment/createSegmentService';
 | 
					export * from './segment/createSegmentService';
 | 
				
			||||||
export * from './dependent-features/createDependentFeaturesService';
 | 
					export * from './dependent-features/createDependentFeaturesService';
 | 
				
			||||||
export * from './tag-type/createTagTypeService';
 | 
					export * from './tag-type/createTagTypeService';
 | 
				
			||||||
 | 
					export * from './project-environments/createEnvironmentService';
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ import {
 | 
				
			|||||||
    IUnleashStores,
 | 
					    IUnleashStores,
 | 
				
			||||||
} from '../../types/stores';
 | 
					} from '../../types/stores';
 | 
				
			||||||
import { IContextFieldStore } from '../../types/stores/context-field-store';
 | 
					import { IContextFieldStore } from '../../types/stores/context-field-store';
 | 
				
			||||||
import { IEnvironmentStore } from '../../types/stores/environment-store';
 | 
					import { IEnvironmentStore } from '../project-environments/environment-store-type';
 | 
				
			||||||
import { IFeatureToggleStore } from '../feature-toggle/types/feature-toggle-store-type';
 | 
					import { IFeatureToggleStore } from '../feature-toggle/types/feature-toggle-store-type';
 | 
				
			||||||
import { IGroupStore } from '../../types/stores/group-store';
 | 
					import { IGroupStore } from '../../types/stores/group-store';
 | 
				
			||||||
import { IProjectStore } from '../../types/stores/project-store';
 | 
					import { IProjectStore } from '../../types/stores/project-store';
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,88 @@
 | 
				
			|||||||
 | 
					import { Db } from '../../db/db';
 | 
				
			||||||
 | 
					import EventStore from '../../db/event-store';
 | 
				
			||||||
 | 
					import { IUnleashConfig } from '../../types';
 | 
				
			||||||
 | 
					import { EventService } from '../../services';
 | 
				
			||||||
 | 
					import FeatureTagStore from '../../db/feature-tag-store';
 | 
				
			||||||
 | 
					import FakeEventStore from '../../../test/fixtures/fake-event-store';
 | 
				
			||||||
 | 
					import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
 | 
				
			||||||
 | 
					import EnvironmentService from './environment-service';
 | 
				
			||||||
 | 
					import EnvironmentStore from './environment-store';
 | 
				
			||||||
 | 
					import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store';
 | 
				
			||||||
 | 
					import { FeatureEnvironmentStore } from '../../db/feature-environment-store';
 | 
				
			||||||
 | 
					import ProjectStore from '../../db/project-store';
 | 
				
			||||||
 | 
					import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
 | 
				
			||||||
 | 
					import FakeProjectStore from '../../../test/fixtures/fake-project-store';
 | 
				
			||||||
 | 
					import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store';
 | 
				
			||||||
 | 
					import FakeEnvironmentStore from './fake-environment-store';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const createEnvironmentService =
 | 
				
			||||||
 | 
					    (config: IUnleashConfig) =>
 | 
				
			||||||
 | 
					    (db: Db): EnvironmentService => {
 | 
				
			||||||
 | 
					        const { getLogger, eventBus, flagResolver } = config;
 | 
				
			||||||
 | 
					        const eventStore = new EventStore(db, getLogger);
 | 
				
			||||||
 | 
					        const featureTagStore = new FeatureTagStore(db, eventBus, getLogger);
 | 
				
			||||||
 | 
					        const featureEnvironmentStore = new FeatureEnvironmentStore(
 | 
				
			||||||
 | 
					            db,
 | 
				
			||||||
 | 
					            eventBus,
 | 
				
			||||||
 | 
					            getLogger,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        const projectStore = new ProjectStore(
 | 
				
			||||||
 | 
					            db,
 | 
				
			||||||
 | 
					            eventBus,
 | 
				
			||||||
 | 
					            getLogger,
 | 
				
			||||||
 | 
					            flagResolver,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        const featureStrategiesStore = new FeatureStrategiesStore(
 | 
				
			||||||
 | 
					            db,
 | 
				
			||||||
 | 
					            eventBus,
 | 
				
			||||||
 | 
					            getLogger,
 | 
				
			||||||
 | 
					            flagResolver,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        const environmentStore = new EnvironmentStore(db, eventBus, getLogger);
 | 
				
			||||||
 | 
					        const eventService = new EventService(
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                eventStore,
 | 
				
			||||||
 | 
					                featureTagStore,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            config,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        return new EnvironmentService(
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                environmentStore,
 | 
				
			||||||
 | 
					                featureStrategiesStore,
 | 
				
			||||||
 | 
					                featureEnvironmentStore,
 | 
				
			||||||
 | 
					                projectStore,
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            config,
 | 
				
			||||||
 | 
					            eventService,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const createFakeEnvironmentService = (
 | 
				
			||||||
 | 
					    config: IUnleashConfig,
 | 
				
			||||||
 | 
					): EnvironmentService => {
 | 
				
			||||||
 | 
					    const eventStore = new FakeEventStore();
 | 
				
			||||||
 | 
					    const featureTagStore = new FakeFeatureTagStore();
 | 
				
			||||||
 | 
					    const featureEnvironmentStore = new FakeFeatureEnvironmentStore();
 | 
				
			||||||
 | 
					    const projectStore = new FakeProjectStore();
 | 
				
			||||||
 | 
					    const featureStrategiesStore = new FakeFeatureStrategiesStore();
 | 
				
			||||||
 | 
					    const environmentStore = new FakeEnvironmentStore();
 | 
				
			||||||
 | 
					    const eventService = new EventService(
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            eventStore,
 | 
				
			||||||
 | 
					            featureTagStore,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        config,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return new EnvironmentService(
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            environmentStore,
 | 
				
			||||||
 | 
					            featureStrategiesStore,
 | 
				
			||||||
 | 
					            featureEnvironmentStore,
 | 
				
			||||||
 | 
					            projectStore,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        config,
 | 
				
			||||||
 | 
					        eventService,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -1,10 +1,10 @@
 | 
				
			|||||||
import EnvironmentService from '../../../lib/services/environment-service';
 | 
					import EnvironmentService from './environment-service';
 | 
				
			||||||
import { createTestConfig } from '../../config/test-config';
 | 
					import { createTestConfig } from '../../../test/config/test-config';
 | 
				
			||||||
import dbInit from '../helpers/database-init';
 | 
					import dbInit from '../../../test/e2e/helpers/database-init';
 | 
				
			||||||
import NotFoundError from '../../../lib/error/notfound-error';
 | 
					import NotFoundError from '../../error/notfound-error';
 | 
				
			||||||
import { IUnleashStores } from '../../../lib/types';
 | 
					import { IUnleashStores } from '../../types';
 | 
				
			||||||
import NameExistsError from '../../../lib/error/name-exists-error';
 | 
					import NameExistsError from '../../error/name-exists-error';
 | 
				
			||||||
import { EventService } from '../../../lib/services';
 | 
					import { EventService } from '../../services';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let stores: IUnleashStores;
 | 
					let stores: IUnleashStores;
 | 
				
			||||||
let db;
 | 
					let db;
 | 
				
			||||||
@ -10,17 +10,17 @@ import {
 | 
				
			|||||||
    IUnleashStores,
 | 
					    IUnleashStores,
 | 
				
			||||||
    PROJECT_ENVIRONMENT_ADDED,
 | 
					    PROJECT_ENVIRONMENT_ADDED,
 | 
				
			||||||
    PROJECT_ENVIRONMENT_REMOVED,
 | 
					    PROJECT_ENVIRONMENT_REMOVED,
 | 
				
			||||||
} from '../types';
 | 
					} from '../../types';
 | 
				
			||||||
import { Logger } from '../logger';
 | 
					import { Logger } from '../../logger';
 | 
				
			||||||
import { BadDataError, UNIQUE_CONSTRAINT_VIOLATION } from '../error';
 | 
					import { BadDataError, UNIQUE_CONSTRAINT_VIOLATION } from '../../error';
 | 
				
			||||||
import NameExistsError from '../error/name-exists-error';
 | 
					import NameExistsError from '../../error/name-exists-error';
 | 
				
			||||||
import { sortOrderSchema } from './state-schema';
 | 
					import { sortOrderSchema } from '../../services/state-schema';
 | 
				
			||||||
import NotFoundError from '../error/notfound-error';
 | 
					import NotFoundError from '../../error/notfound-error';
 | 
				
			||||||
import { IProjectStore } from 'lib/types/stores/project-store';
 | 
					import { IProjectStore } from 'lib/types/stores/project-store';
 | 
				
			||||||
import MinimumOneEnvironmentError from '../error/minimum-one-environment-error';
 | 
					import MinimumOneEnvironmentError from '../../error/minimum-one-environment-error';
 | 
				
			||||||
import { IFlagResolver } from 'lib/types/experimental';
 | 
					import { IFlagResolver } from 'lib/types/experimental';
 | 
				
			||||||
import { CreateFeatureStrategySchema } from '../openapi';
 | 
					import { CreateFeatureStrategySchema } from '../../openapi';
 | 
				
			||||||
import EventService from './event-service';
 | 
					import EventService from '../../services/event-service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class EnvironmentService {
 | 
					export default class EnvironmentService {
 | 
				
			||||||
    private logger: Logger;
 | 
					    private logger: Logger;
 | 
				
			||||||
@ -2,8 +2,8 @@ import {
 | 
				
			|||||||
    IEnvironment,
 | 
					    IEnvironment,
 | 
				
			||||||
    IEnvironmentCreate,
 | 
					    IEnvironmentCreate,
 | 
				
			||||||
    IProjectEnvironment,
 | 
					    IProjectEnvironment,
 | 
				
			||||||
} from '../model';
 | 
					} from '../../types/model';
 | 
				
			||||||
import { Store } from './store';
 | 
					import { Store } from '../../types/stores/store';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IEnvironmentStore extends Store<IEnvironment, string> {
 | 
					export interface IEnvironmentStore extends Store<IEnvironment, string> {
 | 
				
			||||||
    exists(name: string): Promise<boolean>;
 | 
					    exists(name: string): Promise<boolean>;
 | 
				
			||||||
@ -1,17 +1,17 @@
 | 
				
			|||||||
import EventEmitter from 'events';
 | 
					import EventEmitter from 'events';
 | 
				
			||||||
import { Db } from './db';
 | 
					import { Db } from '../../db/db';
 | 
				
			||||||
import { Logger, LogProvider } from '../logger';
 | 
					import { Logger, LogProvider } from '../../logger';
 | 
				
			||||||
import metricsHelper from '../util/metrics-helper';
 | 
					import metricsHelper from '../../util/metrics-helper';
 | 
				
			||||||
import { DB_TIME } from '../metric-events';
 | 
					import { DB_TIME } from '../../metric-events';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    IEnvironment,
 | 
					    IEnvironment,
 | 
				
			||||||
    IEnvironmentCreate,
 | 
					    IEnvironmentCreate,
 | 
				
			||||||
    IProjectEnvironment,
 | 
					    IProjectEnvironment,
 | 
				
			||||||
} from '../types/model';
 | 
					} from '../../types/model';
 | 
				
			||||||
import NotFoundError from '../error/notfound-error';
 | 
					import NotFoundError from '../../error/notfound-error';
 | 
				
			||||||
import { IEnvironmentStore } from '../types/stores/environment-store';
 | 
					import { IEnvironmentStore } from './environment-store-type';
 | 
				
			||||||
import { snakeCaseKeys } from '../util/snakeCase';
 | 
					import { snakeCaseKeys } from '../../util/snakeCase';
 | 
				
			||||||
import { CreateFeatureStrategySchema } from '../openapi';
 | 
					import { CreateFeatureStrategySchema } from '../../openapi';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IEnvironmentsTable {
 | 
					interface IEnvironmentsTable {
 | 
				
			||||||
    name: string;
 | 
					    name: string;
 | 
				
			||||||
@ -1,10 +1,10 @@
 | 
				
			|||||||
import dbInit, { ITestDb } from '../../../helpers/database-init';
 | 
					import dbInit, { ITestDb } from '../../../test/e2e/helpers/database-init';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    IUnleashTest,
 | 
					    IUnleashTest,
 | 
				
			||||||
    setupAppWithCustomConfig,
 | 
					    setupAppWithCustomConfig,
 | 
				
			||||||
} from '../../../helpers/test-helper';
 | 
					} from '../../../test/e2e/helpers/test-helper';
 | 
				
			||||||
import getLogger from '../../../../fixtures/no-logger';
 | 
					import getLogger from '../../../test/fixtures/no-logger';
 | 
				
			||||||
import { DEFAULT_ENV } from '../../../../../lib/util';
 | 
					import { DEFAULT_ENV } from '../../util';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let app: IUnleashTest;
 | 
					let app: IUnleashTest;
 | 
				
			||||||
let db: ITestDb;
 | 
					let db: ITestDb;
 | 
				
			||||||
@ -1,13 +1,13 @@
 | 
				
			|||||||
import { Request, Response } from 'express';
 | 
					import { Request, Response } from 'express';
 | 
				
			||||||
import Controller from '../../controller';
 | 
					import Controller from '../../routes/controller';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    IUnleashConfig,
 | 
					    IUnleashConfig,
 | 
				
			||||||
    IUnleashServices,
 | 
					    IUnleashServices,
 | 
				
			||||||
    serializeDates,
 | 
					    serializeDates,
 | 
				
			||||||
    UPDATE_PROJECT,
 | 
					    UPDATE_PROJECT,
 | 
				
			||||||
} from '../../../types';
 | 
					} from '../../types';
 | 
				
			||||||
import { Logger } from '../../../logger';
 | 
					import { Logger } from '../../logger';
 | 
				
			||||||
import EnvironmentService from '../../../services/environment-service';
 | 
					import EnvironmentService from './environment-service';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    createFeatureStrategySchema,
 | 
					    createFeatureStrategySchema,
 | 
				
			||||||
    CreateFeatureStrategySchema,
 | 
					    CreateFeatureStrategySchema,
 | 
				
			||||||
@ -16,10 +16,11 @@ import {
 | 
				
			|||||||
    emptyResponse,
 | 
					    emptyResponse,
 | 
				
			||||||
    getStandardResponses,
 | 
					    getStandardResponses,
 | 
				
			||||||
    ProjectEnvironmentSchema,
 | 
					    ProjectEnvironmentSchema,
 | 
				
			||||||
} from '../../../openapi';
 | 
					} from '../../openapi';
 | 
				
			||||||
import { OpenApiService, ProjectService } from '../../../services';
 | 
					import { OpenApiService, ProjectService } from '../../services';
 | 
				
			||||||
import { extractUsername } from '../../../util';
 | 
					import { extractUsername } from '../../util';
 | 
				
			||||||
import { IAuthRequest } from '../../unleash-types';
 | 
					import { IAuthRequest } from '../../routes/unleash-types';
 | 
				
			||||||
 | 
					import { WithTransactional } from '../../db/transaction';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const PREFIX = '/:projectId/environments';
 | 
					const PREFIX = '/:projectId/environments';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -31,7 +32,7 @@ interface IProjectEnvironmentParams {
 | 
				
			|||||||
export default class EnvironmentsController extends Controller {
 | 
					export default class EnvironmentsController extends Controller {
 | 
				
			||||||
    private logger: Logger;
 | 
					    private logger: Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private environmentService: EnvironmentService;
 | 
					    private environmentService: WithTransactional<EnvironmentService>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private openApiService: OpenApiService;
 | 
					    private openApiService: OpenApiService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -40,18 +41,20 @@ export default class EnvironmentsController extends Controller {
 | 
				
			|||||||
    constructor(
 | 
					    constructor(
 | 
				
			||||||
        config: IUnleashConfig,
 | 
					        config: IUnleashConfig,
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            environmentService,
 | 
					            transactionalEnvironmentService,
 | 
				
			||||||
            openApiService,
 | 
					            openApiService,
 | 
				
			||||||
            projectService,
 | 
					            projectService,
 | 
				
			||||||
        }: Pick<
 | 
					        }: Pick<
 | 
				
			||||||
            IUnleashServices,
 | 
					            IUnleashServices,
 | 
				
			||||||
            'environmentService' | 'openApiService' | 'projectService'
 | 
					            | 'transactionalEnvironmentService'
 | 
				
			||||||
 | 
					            | 'openApiService'
 | 
				
			||||||
 | 
					            | 'projectService'
 | 
				
			||||||
        >,
 | 
					        >,
 | 
				
			||||||
    ) {
 | 
					    ) {
 | 
				
			||||||
        super(config);
 | 
					        super(config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.logger = config.getLogger('admin-api/project/environments.ts');
 | 
					        this.logger = config.getLogger('admin-api/project/environments.ts');
 | 
				
			||||||
        this.environmentService = environmentService;
 | 
					        this.environmentService = transactionalEnvironmentService;
 | 
				
			||||||
        this.openApiService = openApiService;
 | 
					        this.openApiService = openApiService;
 | 
				
			||||||
        this.projectService = projectService;
 | 
					        this.projectService = projectService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -137,10 +140,12 @@ export default class EnvironmentsController extends Controller {
 | 
				
			|||||||
        const { environment } = req.body;
 | 
					        const { environment } = req.body;
 | 
				
			||||||
        await this.projectService.getProject(projectId); // Validates that the project exists
 | 
					        await this.projectService.getProject(projectId); // Validates that the project exists
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await this.environmentService.addEnvironmentToProject(
 | 
					        await this.environmentService.transactional((service) =>
 | 
				
			||||||
            environment,
 | 
					            service.addEnvironmentToProject(
 | 
				
			||||||
            projectId,
 | 
					                environment,
 | 
				
			||||||
            extractUsername(req),
 | 
					                projectId,
 | 
				
			||||||
 | 
					                extractUsername(req),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        res.status(200).end();
 | 
					        res.status(200).end();
 | 
				
			||||||
@ -152,10 +157,12 @@ export default class EnvironmentsController extends Controller {
 | 
				
			|||||||
    ): Promise<void> {
 | 
					    ): Promise<void> {
 | 
				
			||||||
        const { projectId, environment } = req.params;
 | 
					        const { projectId, environment } = req.params;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await this.environmentService.removeEnvironmentFromProject(
 | 
					        await this.environmentService.transactional((service) =>
 | 
				
			||||||
            environment,
 | 
					            service.removeEnvironmentFromProject(
 | 
				
			||||||
            projectId,
 | 
					                environment,
 | 
				
			||||||
            extractUsername(req),
 | 
					                projectId,
 | 
				
			||||||
 | 
					                extractUsername(req),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        res.status(200).end();
 | 
					        res.status(200).end();
 | 
				
			||||||
@ -171,11 +178,13 @@ export default class EnvironmentsController extends Controller {
 | 
				
			|||||||
        const { projectId, environment } = req.params;
 | 
					        const { projectId, environment } = req.params;
 | 
				
			||||||
        const strategy = req.body;
 | 
					        const strategy = req.body;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const saved = await this.environmentService.updateDefaultStrategy(
 | 
					        const saved = await this.environmentService.transactional((service) =>
 | 
				
			||||||
            environment,
 | 
					            service.updateDefaultStrategy(
 | 
				
			||||||
            projectId,
 | 
					                environment,
 | 
				
			||||||
            strategy,
 | 
					                projectId,
 | 
				
			||||||
            extractUsername(req),
 | 
					                strategy,
 | 
				
			||||||
 | 
					                extractUsername(req),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.openApiService.respondWithValidation(
 | 
					        this.openApiService.respondWithValidation(
 | 
				
			||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import { IEnvironment, IProjectEnvironment } from '../../lib/types/model';
 | 
					import { IEnvironment, IProjectEnvironment } from '../../types/model';
 | 
				
			||||||
import NotFoundError from '../../lib/error/notfound-error';
 | 
					import NotFoundError from '../../error/notfound-error';
 | 
				
			||||||
import { IEnvironmentStore } from '../../lib/types/stores/environment-store';
 | 
					import { IEnvironmentStore } from './environment-store-type';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class FakeEnvironmentStore implements IEnvironmentStore {
 | 
					export default class FakeEnvironmentStore implements IEnvironmentStore {
 | 
				
			||||||
    importEnvironments(envs: IEnvironment[]): Promise<IEnvironment[]> {
 | 
					    importEnvironments(envs: IEnvironment[]): Promise<IEnvironment[]> {
 | 
				
			||||||
@ -2,7 +2,7 @@ import { Db, IUnleashConfig } from 'lib/server-impl';
 | 
				
			|||||||
import EventStore from '../../db/event-store';
 | 
					import EventStore from '../../db/event-store';
 | 
				
			||||||
import GroupStore from '../../db/group-store';
 | 
					import GroupStore from '../../db/group-store';
 | 
				
			||||||
import { AccountStore } from '../../db/account-store';
 | 
					import { AccountStore } from '../../db/account-store';
 | 
				
			||||||
import EnvironmentStore from '../../db/environment-store';
 | 
					import EnvironmentStore from '../project-environments/environment-store';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    AccessService,
 | 
					    AccessService,
 | 
				
			||||||
    EventService,
 | 
					    EventService,
 | 
				
			||||||
@ -28,7 +28,7 @@ import { FavoriteFeaturesStore } from '../../db/favorite-features-store';
 | 
				
			|||||||
import { FavoriteProjectsStore } from '../../db/favorite-projects-store';
 | 
					import { FavoriteProjectsStore } from '../../db/favorite-projects-store';
 | 
				
			||||||
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
 | 
					import FakeProjectStore from '../../../test/fixtures/fake-project-store';
 | 
				
			||||||
import FakeFeatureToggleStore from '../feature-toggle/fakes/fake-feature-toggle-store';
 | 
					import FakeFeatureToggleStore from '../feature-toggle/fakes/fake-feature-toggle-store';
 | 
				
			||||||
import FakeEnvironmentStore from '../../../test/fixtures/fake-environment-store';
 | 
					import FakeEnvironmentStore from '../project-environments/fake-environment-store';
 | 
				
			||||||
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
 | 
					import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
 | 
				
			||||||
import FakeProjectStatsStore from '../../../test/fixtures/fake-project-stats-store';
 | 
					import FakeProjectStatsStore from '../../../test/fixtures/fake-project-stats-store';
 | 
				
			||||||
import FakeFavoriteFeaturesStore from '../../../test/fixtures/fake-favorite-features-store';
 | 
					import FakeFavoriteFeaturesStore from '../../../test/fixtures/fake-favorite-features-store';
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@ import { Request, Response } from 'express';
 | 
				
			|||||||
import Controller from '../controller';
 | 
					import Controller from '../controller';
 | 
				
			||||||
import { IUnleashServices } from '../../types/services';
 | 
					import { IUnleashServices } from '../../types/services';
 | 
				
			||||||
import { IUnleashConfig } from '../../types/option';
 | 
					import { IUnleashConfig } from '../../types/option';
 | 
				
			||||||
import EnvironmentService from '../../services/environment-service';
 | 
					import EnvironmentService from '../../features/project-environments/environment-service';
 | 
				
			||||||
import { Logger } from '../../logger';
 | 
					import { Logger } from '../../logger';
 | 
				
			||||||
import { ADMIN, NONE } from '../../types/permissions';
 | 
					import { ADMIN, NONE } from '../../types/permissions';
 | 
				
			||||||
import { OpenApiService } from '../../services/openapi-service';
 | 
					import { OpenApiService } from '../../services/openapi-service';
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ import {
 | 
				
			|||||||
    serializeDates,
 | 
					    serializeDates,
 | 
				
			||||||
} from '../../../types';
 | 
					} from '../../../types';
 | 
				
			||||||
import ProjectFeaturesController from '../../../features/feature-toggle/feature-toggle-controller';
 | 
					import ProjectFeaturesController from '../../../features/feature-toggle/feature-toggle-controller';
 | 
				
			||||||
import EnvironmentsController from './environments';
 | 
					import EnvironmentsController from '../../../features/project-environments/environments';
 | 
				
			||||||
import ProjectHealthReport from './health-report';
 | 
					import ProjectHealthReport from './health-report';
 | 
				
			||||||
import ProjectService from '../../../services/project-service';
 | 
					import ProjectService from '../../../services/project-service';
 | 
				
			||||||
import VariantsController from './variants';
 | 
					import VariantsController from './variants';
 | 
				
			||||||
 | 
				
			|||||||
@ -11,7 +11,7 @@ import { CUSTOM_ROOT_ROLE_TYPE } from '../util/constants';
 | 
				
			|||||||
import FakeGroupStore from '../../test/fixtures/fake-group-store';
 | 
					import FakeGroupStore from '../../test/fixtures/fake-group-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 '../../test/fixtures/fake-environment-store';
 | 
					import FakeEnvironmentStore from '../features/project-environments/fake-environment-store';
 | 
				
			||||||
import AccessStoreMock from '../../test/fixtures/fake-access-store';
 | 
					import AccessStoreMock from '../../test/fixtures/fake-access-store';
 | 
				
			||||||
import { GroupService } from '../services/group-service';
 | 
					import { GroupService } from '../services/group-service';
 | 
				
			||||||
import FakeEventStore from '../../test/fixtures/fake-event-store';
 | 
					import FakeEventStore from '../../test/fixtures/fake-event-store';
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ import {
 | 
				
			|||||||
} from '../types/model';
 | 
					} from '../types/model';
 | 
				
			||||||
import { IRoleStore } from '../types/stores/role-store';
 | 
					import { IRoleStore } from '../types/stores/role-store';
 | 
				
			||||||
import NameExistsError from '../error/name-exists-error';
 | 
					import NameExistsError from '../error/name-exists-error';
 | 
				
			||||||
import { IEnvironmentStore } from '../types/stores/environment-store';
 | 
					import { IEnvironmentStore } from '../features/project-environments/environment-store-type';
 | 
				
			||||||
import RoleInUseError from '../error/role-in-use-error';
 | 
					import RoleInUseError from '../error/role-in-use-error';
 | 
				
			||||||
import { roleSchema } from '../schema/role-schema';
 | 
					import { roleSchema } from '../schema/role-schema';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@ import { createTestConfig } from '../../test/config/test-config';
 | 
				
			|||||||
import { IUnleashConfig } from '../server-impl';
 | 
					import { IUnleashConfig } from '../server-impl';
 | 
				
			||||||
import { ApiTokenType, IApiTokenCreate } from '../types/models/api-token';
 | 
					import { ApiTokenType, IApiTokenCreate } from '../types/models/api-token';
 | 
				
			||||||
import FakeApiTokenStore from '../../test/fixtures/fake-api-token-store';
 | 
					import FakeApiTokenStore from '../../test/fixtures/fake-api-token-store';
 | 
				
			||||||
import FakeEnvironmentStore from '../../test/fixtures/fake-environment-store';
 | 
					import FakeEnvironmentStore from '../features/project-environments/fake-environment-store';
 | 
				
			||||||
import FakeEventStore from '../../test/fixtures/fake-event-store';
 | 
					import FakeEventStore from '../../test/fixtures/fake-event-store';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    API_TOKEN_CREATED,
 | 
					    API_TOKEN_CREATED,
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@ import {
 | 
				
			|||||||
import { IApiTokenStore } from '../types/stores/api-token-store';
 | 
					import { IApiTokenStore } from '../types/stores/api-token-store';
 | 
				
			||||||
import { FOREIGN_KEY_VIOLATION } from '../error/db-error';
 | 
					import { FOREIGN_KEY_VIOLATION } from '../error/db-error';
 | 
				
			||||||
import BadDataError from '../error/bad-data-error';
 | 
					import BadDataError from '../error/bad-data-error';
 | 
				
			||||||
import { IEnvironmentStore } from 'lib/types/stores/environment-store';
 | 
					import { IEnvironmentStore } from 'lib/features/project-environments/environment-store-type';
 | 
				
			||||||
import { constantTimeCompare } from '../util/constantTimeCompare';
 | 
					import { constantTimeCompare } from '../util/constantTimeCompare';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    ApiTokenCreatedEvent,
 | 
					    ApiTokenCreatedEvent,
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,7 @@ import SettingService from './setting-service';
 | 
				
			|||||||
import SessionService from './session-service';
 | 
					import SessionService from './session-service';
 | 
				
			||||||
import UserFeedbackService from './user-feedback-service';
 | 
					import UserFeedbackService from './user-feedback-service';
 | 
				
			||||||
import FeatureToggleService from '../features/feature-toggle/feature-toggle-service';
 | 
					import FeatureToggleService from '../features/feature-toggle/feature-toggle-service';
 | 
				
			||||||
import EnvironmentService from './environment-service';
 | 
					import EnvironmentService from '../features/project-environments/environment-service';
 | 
				
			||||||
import FeatureTagService from './feature-tag-service';
 | 
					import FeatureTagService from './feature-tag-service';
 | 
				
			||||||
import ProjectHealthService from './project-health-service';
 | 
					import ProjectHealthService from './project-health-service';
 | 
				
			||||||
import UserSplashService from './user-splash-service';
 | 
					import UserSplashService from './user-splash-service';
 | 
				
			||||||
@ -59,6 +59,8 @@ import {
 | 
				
			|||||||
} from '../features/change-request-segment-usage-service/createChangeRequestSegmentUsageReadModel';
 | 
					} from '../features/change-request-segment-usage-service/createChangeRequestSegmentUsageReadModel';
 | 
				
			||||||
import ConfigurationRevisionService from '../features/feature-toggle/configuration-revision-service';
 | 
					import ConfigurationRevisionService from '../features/feature-toggle/configuration-revision-service';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
 | 
					    createEnvironmentService,
 | 
				
			||||||
 | 
					    createFakeEnvironmentService,
 | 
				
			||||||
    createFakeProjectService,
 | 
					    createFakeProjectService,
 | 
				
			||||||
    createFeatureToggleService,
 | 
					    createFeatureToggleService,
 | 
				
			||||||
    createProjectService,
 | 
					    createProjectService,
 | 
				
			||||||
@ -229,11 +231,11 @@ export const createServices = (
 | 
				
			|||||||
        dependentFeaturesReadModel,
 | 
					        dependentFeaturesReadModel,
 | 
				
			||||||
        dependentFeaturesService,
 | 
					        dependentFeaturesService,
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    const environmentService = new EnvironmentService(
 | 
					    const transactionalEnvironmentService = db
 | 
				
			||||||
        stores,
 | 
					        ? withTransactional(createEnvironmentService(config), db)
 | 
				
			||||||
        config,
 | 
					        : withFakeTransactional(createFakeEnvironmentService(config));
 | 
				
			||||||
        eventService,
 | 
					    const environmentService = transactionalEnvironmentService;
 | 
				
			||||||
    );
 | 
					
 | 
				
			||||||
    const featureTagService = new FeatureTagService(
 | 
					    const featureTagService = new FeatureTagService(
 | 
				
			||||||
        stores,
 | 
					        stores,
 | 
				
			||||||
        config,
 | 
					        config,
 | 
				
			||||||
@ -340,6 +342,7 @@ export const createServices = (
 | 
				
			|||||||
        resetTokenService,
 | 
					        resetTokenService,
 | 
				
			||||||
        eventService,
 | 
					        eventService,
 | 
				
			||||||
        environmentService,
 | 
					        environmentService,
 | 
				
			||||||
 | 
					        transactionalEnvironmentService,
 | 
				
			||||||
        settingService,
 | 
					        settingService,
 | 
				
			||||||
        sessionService,
 | 
					        sessionService,
 | 
				
			||||||
        userFeedbackService,
 | 
					        userFeedbackService,
 | 
				
			||||||
 | 
				
			|||||||
@ -45,7 +45,7 @@ import { ITagStore } from '../types/stores/tag-store';
 | 
				
			|||||||
import { IStrategy, IStrategyStore } from '../types/stores/strategy-store';
 | 
					import { IStrategy, IStrategyStore } from '../types/stores/strategy-store';
 | 
				
			||||||
import { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type';
 | 
					import { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type';
 | 
				
			||||||
import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type';
 | 
					import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type';
 | 
				
			||||||
import { IEnvironmentStore } from '../types/stores/environment-store';
 | 
					import { IEnvironmentStore } from '../features/project-environments/environment-store-type';
 | 
				
			||||||
import { IFeatureEnvironmentStore } from '../types/stores/feature-environment-store';
 | 
					import { IFeatureEnvironmentStore } from '../types/stores/feature-environment-store';
 | 
				
			||||||
import { IUnleashStores } from '../types/stores';
 | 
					import { IUnleashStores } from '../types/stores';
 | 
				
			||||||
import { DEFAULT_ENV } from '../util/constants';
 | 
					import { DEFAULT_ENV } from '../util/constants';
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,7 @@ import SettingService from '../services/setting-service';
 | 
				
			|||||||
import SessionService from '../services/session-service';
 | 
					import SessionService from '../services/session-service';
 | 
				
			||||||
import UserFeedbackService from '../services/user-feedback-service';
 | 
					import UserFeedbackService from '../services/user-feedback-service';
 | 
				
			||||||
import FeatureToggleService from '../features/feature-toggle/feature-toggle-service';
 | 
					import FeatureToggleService from '../features/feature-toggle/feature-toggle-service';
 | 
				
			||||||
import EnvironmentService from '../services/environment-service';
 | 
					import EnvironmentService from '../features/project-environments/environment-service';
 | 
				
			||||||
import FeatureTagService from '../services/feature-tag-service';
 | 
					import FeatureTagService from '../services/feature-tag-service';
 | 
				
			||||||
import ProjectHealthService from '../services/project-health-service';
 | 
					import ProjectHealthService from '../services/project-health-service';
 | 
				
			||||||
import ClientMetricsServiceV2 from '../services/client-metrics/metrics-service-v2';
 | 
					import ClientMetricsServiceV2 from '../services/client-metrics/metrics-service-v2';
 | 
				
			||||||
@ -62,6 +62,7 @@ export interface IUnleashServices {
 | 
				
			|||||||
    contextService: ContextService;
 | 
					    contextService: ContextService;
 | 
				
			||||||
    emailService: EmailService;
 | 
					    emailService: EmailService;
 | 
				
			||||||
    environmentService: EnvironmentService;
 | 
					    environmentService: EnvironmentService;
 | 
				
			||||||
 | 
					    transactionalEnvironmentService: WithTransactional<EnvironmentService>;
 | 
				
			||||||
    eventService: EventService;
 | 
					    eventService: EventService;
 | 
				
			||||||
    edgeService: EdgeService;
 | 
					    edgeService: EdgeService;
 | 
				
			||||||
    featureTagService: FeatureTagService;
 | 
					    featureTagService: FeatureTagService;
 | 
				
			||||||
 | 
				
			|||||||
@ -19,7 +19,7 @@ import { IResetTokenStore } from './stores/reset-token-store';
 | 
				
			|||||||
import { IUserFeedbackStore } from './stores/user-feedback-store';
 | 
					import { IUserFeedbackStore } from './stores/user-feedback-store';
 | 
				
			||||||
import { IFeatureEnvironmentStore } from './stores/feature-environment-store';
 | 
					import { IFeatureEnvironmentStore } from './stores/feature-environment-store';
 | 
				
			||||||
import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type';
 | 
					import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type';
 | 
				
			||||||
import { IEnvironmentStore } from './stores/environment-store';
 | 
					import { IEnvironmentStore } from '../features/project-environments/environment-store-type';
 | 
				
			||||||
import { IFeatureToggleClientStore } from '../features/client-feature-toggles/types/client-feature-toggle-store-type';
 | 
					import { IFeatureToggleClientStore } from '../features/client-feature-toggles/types/client-feature-toggle-store-type';
 | 
				
			||||||
import { IClientMetricsStoreV2 } from './stores/client-metrics-store-v2';
 | 
					import { IClientMetricsStoreV2 } from './stores/client-metrics-store-v2';
 | 
				
			||||||
import { IUserSplashStore } from './stores/user-splash-store';
 | 
					import { IUserSplashStore } from './stores/user-splash-store';
 | 
				
			||||||
 | 
				
			|||||||
@ -11,13 +11,17 @@ let db: ITestDb;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
beforeAll(async () => {
 | 
					beforeAll(async () => {
 | 
				
			||||||
    db = await dbInit('environment_api_serial', getLogger);
 | 
					    db = await dbInit('environment_api_serial', getLogger);
 | 
				
			||||||
    app = await setupAppWithCustomConfig(db.stores, {
 | 
					    app = await setupAppWithCustomConfig(
 | 
				
			||||||
        experimental: {
 | 
					        db.stores,
 | 
				
			||||||
            flags: {
 | 
					        {
 | 
				
			||||||
                strictSchemaValidation: true,
 | 
					            experimental: {
 | 
				
			||||||
 | 
					                flags: {
 | 
				
			||||||
 | 
					                    strictSchemaValidation: true,
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    });
 | 
					        db.rawDatabase,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
afterAll(async () => {
 | 
					afterAll(async () => {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,9 @@
 | 
				
			|||||||
import dbInit, { ITestDb } from '../../helpers/database-init';
 | 
					import dbInit, { ITestDb } from '../../helpers/database-init';
 | 
				
			||||||
import { IUnleashTest, setupApp } from '../../helpers/test-helper';
 | 
					import {
 | 
				
			||||||
 | 
					    IUnleashTest,
 | 
				
			||||||
 | 
					    setupApp,
 | 
				
			||||||
 | 
					    setupAppWithCustomConfig,
 | 
				
			||||||
 | 
					} from '../../helpers/test-helper';
 | 
				
			||||||
import getLogger from '../../../fixtures/no-logger';
 | 
					import getLogger from '../../../fixtures/no-logger';
 | 
				
			||||||
import { DEFAULT_ENV } from '../../../../lib/util/constants';
 | 
					import { DEFAULT_ENV } from '../../../../lib/util/constants';
 | 
				
			||||||
import { collectIds } from '../../../../lib/util/collect-ids';
 | 
					import { collectIds } from '../../../../lib/util/collect-ids';
 | 
				
			||||||
@ -12,7 +16,17 @@ let db: ITestDb;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
beforeAll(async () => {
 | 
					beforeAll(async () => {
 | 
				
			||||||
    db = await dbInit('state_api_serial', getLogger);
 | 
					    db = await dbInit('state_api_serial', getLogger);
 | 
				
			||||||
    app = await setupApp(db.stores);
 | 
					    app = await setupAppWithCustomConfig(
 | 
				
			||||||
 | 
					        db.stores,
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            experimental: {
 | 
				
			||||||
 | 
					                flags: {
 | 
				
			||||||
 | 
					                    strictSchemaValidation: true,
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        db.rawDatabase,
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
afterAll(async () => {
 | 
					afterAll(async () => {
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ import { createTestConfig } from '../../config/test-config';
 | 
				
			|||||||
import dbState from './database.json';
 | 
					import dbState from './database.json';
 | 
				
			||||||
import { LogProvider } from '../../../lib/logger';
 | 
					import { LogProvider } from '../../../lib/logger';
 | 
				
			||||||
import noLoggerProvider from '../../fixtures/no-logger';
 | 
					import noLoggerProvider from '../../fixtures/no-logger';
 | 
				
			||||||
import EnvironmentStore from '../../../lib/db/environment-store';
 | 
					import EnvironmentStore from '../../../lib/features/project-environments/environment-store';
 | 
				
			||||||
import { IUnleashStores } from '../../../lib/types';
 | 
					import { IUnleashStores } from '../../../lib/types';
 | 
				
			||||||
import { IFeatureEnvironmentStore } from '../../../lib/types/stores/feature-environment-store';
 | 
					import { IFeatureEnvironmentStore } from '../../../lib/types/stores/feature-environment-store';
 | 
				
			||||||
import { DEFAULT_ENV } from '../../../lib/util/constants';
 | 
					import { DEFAULT_ENV } from '../../../lib/util/constants';
 | 
				
			||||||
 | 
				
			|||||||
@ -7,7 +7,7 @@ import { MOVE_FEATURE_TOGGLE } from '../../../lib/types/permissions';
 | 
				
			|||||||
import { createTestConfig } from '../../config/test-config';
 | 
					import { createTestConfig } from '../../config/test-config';
 | 
				
			||||||
import { RoleName } from '../../../lib/types/model';
 | 
					import { RoleName } from '../../../lib/types/model';
 | 
				
			||||||
import { randomId } from '../../../lib/util/random-id';
 | 
					import { randomId } from '../../../lib/util/random-id';
 | 
				
			||||||
import EnvironmentService from '../../../lib/services/environment-service';
 | 
					import EnvironmentService from '../../../lib/features/project-environments/environment-service';
 | 
				
			||||||
import IncompatibleProjectError from '../../../lib/error/incompatible-project-error';
 | 
					import IncompatibleProjectError from '../../../lib/error/incompatible-project-error';
 | 
				
			||||||
import { EventService } from '../../../lib/services';
 | 
					import { EventService } from '../../../lib/services';
 | 
				
			||||||
import { FeatureEnvironmentEvent } from '../../../lib/types/events';
 | 
					import { FeatureEnvironmentEvent } from '../../../lib/types/events';
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@ import dbInit from '../helpers/database-init';
 | 
				
			|||||||
import getLogger from '../../fixtures/no-logger';
 | 
					import getLogger from '../../fixtures/no-logger';
 | 
				
			||||||
import { IFeatureEnvironmentStore } from '../../../lib/types/stores/feature-environment-store';
 | 
					import { IFeatureEnvironmentStore } from '../../../lib/types/stores/feature-environment-store';
 | 
				
			||||||
import { IFeatureToggleStore } from '../../../lib/features/feature-toggle/types/feature-toggle-store-type';
 | 
					import { IFeatureToggleStore } from '../../../lib/features/feature-toggle/types/feature-toggle-store-type';
 | 
				
			||||||
import { IEnvironmentStore } from '../../../lib/types/stores/environment-store';
 | 
					import { IEnvironmentStore } from '../../../lib/features/project-environments/environment-store-type';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let db;
 | 
					let db;
 | 
				
			||||||
let stores: IUnleashStores;
 | 
					let stores: IUnleashStores;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
import { IProjectInsert, IProjectStore } from 'lib/types/stores/project-store';
 | 
					import { IProjectInsert, IProjectStore } from 'lib/types/stores/project-store';
 | 
				
			||||||
import { IEnvironmentStore } from 'lib/types/stores/environment-store';
 | 
					import { IEnvironmentStore } from 'lib/features/project-environments/environment-store-type';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import dbInit from '../helpers/database-init';
 | 
					import dbInit from '../helpers/database-init';
 | 
				
			||||||
import getLogger from '../../fixtures/no-logger';
 | 
					import getLogger from '../../fixtures/no-logger';
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								src/test/fixtures/store.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/test/fixtures/store.ts
									
									
									
									
										vendored
									
									
								
							@ -13,7 +13,7 @@ import FakeUserStore from './fake-user-store';
 | 
				
			|||||||
import FakeAccessStore from './fake-access-store';
 | 
					import FakeAccessStore from './fake-access-store';
 | 
				
			||||||
import FakeUserFeedbackStore from './fake-user-feedback-store';
 | 
					import FakeUserFeedbackStore from './fake-user-feedback-store';
 | 
				
			||||||
import FakeFeatureTagStore from './fake-feature-tag-store';
 | 
					import FakeFeatureTagStore from './fake-feature-tag-store';
 | 
				
			||||||
import FakeEnvironmentStore from './fake-environment-store';
 | 
					import FakeEnvironmentStore from '../../lib/features/project-environments/fake-environment-store';
 | 
				
			||||||
import FakeStrategiesStore from './fake-strategies-store';
 | 
					import FakeStrategiesStore from './fake-strategies-store';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
    IImportTogglesStore,
 | 
					    IImportTogglesStore,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user