diff --git a/src/lib/db/feature-strategy-store.test.ts b/src/lib/db/feature-strategy-store.test.ts index 156ab07373d1..049af1c2f67f 100644 --- a/src/lib/db/feature-strategy-store.test.ts +++ b/src/lib/db/feature-strategy-store.test.ts @@ -1,7 +1,7 @@ import dbInit from '../../test/e2e/helpers/database-init'; import getLogger from '../../test/fixtures/no-logger'; -import FeatureStrategiesStore from './feature-strategy-store'; -import FeatureToggleStore from './feature-toggle-store'; +import FeatureStrategiesStore from '../features/feature-toggle/feature-toggle-strategies-store'; +import FeatureToggleStore from '../features/feature-toggle/feature-toggle-store'; import StrategyStore from './strategy-store'; import { IFeatureStrategy, PartialSome } from '../types'; diff --git a/src/lib/db/feature-toggle-client-store.ts b/src/lib/db/feature-toggle-client-store.ts index 13f537f4b848..8c57afae8fae 100644 --- a/src/lib/db/feature-toggle-client-store.ts +++ b/src/lib/db/feature-toggle-client-store.ts @@ -13,7 +13,7 @@ import { } from '../types'; import { DEFAULT_ENV, ensureStringValue, mapValues } from '../util'; import EventEmitter from 'events'; -import FeatureToggleStore from './feature-toggle-store'; +import FeatureToggleStore from '../features/feature-toggle/feature-toggle-store'; import { Db } from './db'; import Raw = Knex.Raw; diff --git a/src/lib/db/index.ts b/src/lib/db/index.ts index 6d4c41f0d952..506d8361e587 100644 --- a/src/lib/db/index.ts +++ b/src/lib/db/index.ts @@ -1,7 +1,7 @@ import { IUnleashConfig, IUnleashStores } from '../types'; import EventStore from './event-store'; -import FeatureToggleStore from './feature-toggle-store'; +import FeatureToggleStore from '../features/feature-toggle/feature-toggle-store'; import FeatureTypeStore from './feature-type-store'; import StrategyStore from './strategy-store'; import ClientInstanceStore from './client-instance-store'; @@ -18,7 +18,7 @@ import SessionStore from './session-store'; import { AccessStore } from './access-store'; import { ResetTokenStore } from './reset-token-store'; import UserFeedbackStore from './user-feedback-store'; -import FeatureStrategyStore from './feature-strategy-store'; +import FeatureStrategyStore from '../features/feature-toggle/feature-toggle-strategies-store'; import FeatureToggleClientStore from './feature-toggle-client-store'; import EnvironmentStore from './environment-store'; import FeatureTagStore from './feature-tag-store'; diff --git a/src/lib/features/export-import-toggles/createExportImportService.ts b/src/lib/features/export-import-toggles/createExportImportService.ts index e8a589f6ba92..b5ffe55df375 100644 --- a/src/lib/features/export-import-toggles/createExportImportService.ts +++ b/src/lib/features/export-import-toggles/createExportImportService.ts @@ -2,14 +2,14 @@ import { Db } from '../../db/db'; import { IUnleashConfig } from '../../types'; import ExportImportService from './export-import-service'; import { ImportTogglesStore } from './import-toggles-store'; -import FeatureToggleStore from '../../db/feature-toggle-store'; +import FeatureToggleStore from '../feature-toggle/feature-toggle-store'; import TagStore from '../../db/tag-store'; import TagTypeStore from '../../db/tag-type-store'; import ProjectStore from '../../db/project-store'; import FeatureTagStore from '../../db/feature-tag-store'; import StrategyStore from '../../db/strategy-store'; import ContextFieldStore from '../../db/context-field-store'; -import FeatureStrategiesStore from '../../db/feature-strategy-store'; +import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store'; import { ContextService, EventService, @@ -27,7 +27,7 @@ import { } from '../feature-toggle/createFeatureToggleService'; import SegmentStore from '../../db/segment-store'; import { FeatureEnvironmentStore } from '../../db/feature-environment-store'; -import FakeFeatureToggleStore from '../../../test/fixtures/fake-feature-toggle-store'; +import FakeFeatureToggleStore from '../feature-toggle/fakes/fake-feature-toggle-store'; import FakeTagStore from '../../../test/fixtures/fake-tag-store'; import FakeTagTypeStore from '../../../test/fixtures/fake-tag-type-store'; import FakeSegmentStore from '../../../test/fixtures/fake-segment-store'; @@ -35,7 +35,7 @@ import FakeProjectStore from '../../../test/fixtures/fake-project-store'; import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store'; import FakeContextFieldStore from '../../../test/fixtures/fake-context-field-store'; import FakeEventStore from '../../../test/fixtures/fake-event-store'; -import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store'; +import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store'; import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store'; import FakeStrategiesStore from '../../../test/fixtures/fake-strategies-store'; import EventStore from '../../db/event-store'; diff --git a/src/lib/features/export-import-toggles/export-import-service.ts b/src/lib/features/export-import-toggles/export-import-service.ts index a480171756c0..29a7599b5932 100644 --- a/src/lib/features/export-import-toggles/export-import-service.ts +++ b/src/lib/features/export-import-toggles/export-import-service.ts @@ -9,8 +9,8 @@ import { Logger } from '../../logger'; import { IFeatureTagStore } from '../../types/stores/feature-tag-store'; import { ITagTypeStore } from '../../types/stores/tag-type-store'; import { IStrategy } from '../../types/stores/strategy-store'; -import { IFeatureToggleStore } from '../../types/stores/feature-toggle-store'; -import { IFeatureStrategiesStore } from '../../types/stores/feature-strategies-store'; +import { IFeatureToggleStore } from '../feature-toggle/types/feature-toggle-store-type'; +import { IFeatureStrategiesStore } from '../feature-toggle/types/feature-toggle-strategies-store-type'; import { IFeatureEnvironmentStore } from '../../types/stores/feature-environment-store'; import { IContextFieldStore, IUnleashStores } from '../../types/stores'; import { ISegmentStore } from '../../types/stores/segment-store'; @@ -48,7 +48,7 @@ import { import { ImportPermissionsService, Mode } from './import-permissions-service'; import { ImportValidationMessages } from './import-validation-messages'; import { findDuplicates } from '../../util/findDuplicates'; -import { FeatureNameCheckResultWithFeaturePattern } from '../../services/feature-toggle-service'; +import { FeatureNameCheckResultWithFeaturePattern } from '../feature-toggle/feature-toggle-service'; export default class ExportImportService { private logger: Logger; diff --git a/src/lib/features/export-import-toggles/import-validation-messages.ts b/src/lib/features/export-import-toggles/import-validation-messages.ts index 473db08df1ea..07bc206551df 100644 --- a/src/lib/features/export-import-toggles/import-validation-messages.ts +++ b/src/lib/features/export-import-toggles/import-validation-messages.ts @@ -3,7 +3,7 @@ import { ImportTogglesValidateItemSchema, } from '../../openapi'; import { IContextFieldDto } from '../../types/stores/context-field-store'; -import { FeatureNameCheckResultWithFeaturePattern } from '../../services/feature-toggle-service'; +import { FeatureNameCheckResultWithFeaturePattern } from '../feature-toggle/feature-toggle-service'; import { ProjectFeaturesLimit } from './import-toggles-store-type'; export interface IErrorsParams { diff --git a/src/lib/features/feature-toggle/createFeatureToggleService.ts b/src/lib/features/feature-toggle/createFeatureToggleService.ts index aa6af416f471..2df14f0cf133 100644 --- a/src/lib/features/feature-toggle/createFeatureToggleService.ts +++ b/src/lib/features/feature-toggle/createFeatureToggleService.ts @@ -4,8 +4,8 @@ import { FeatureToggleService, GroupService, } from '../../services'; -import FeatureStrategiesStore from '../../db/feature-strategy-store'; -import FeatureToggleStore from '../../db/feature-toggle-store'; +import FeatureStrategiesStore from './feature-toggle-strategies-store'; +import FeatureToggleStore from './feature-toggle-store'; import FeatureToggleClientStore from '../../db/feature-toggle-client-store'; import ProjectStore from '../../db/project-store'; import { FeatureEnvironmentStore } from '../../db/feature-environment-store'; @@ -18,8 +18,8 @@ import EnvironmentStore from '../../db/environment-store'; import { Db } from '../../db/db'; import { IUnleashConfig } from '../../types'; import FakeEventStore from '../../../test/fixtures/fake-event-store'; -import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store'; -import FakeFeatureToggleStore from '../../../test/fixtures/fake-feature-toggle-store'; +import FakeFeatureStrategiesStore from './fakes/fake-feature-strategies-store'; +import FakeFeatureToggleStore from './fakes/fake-feature-toggle-store'; import FakeFeatureToggleClientStore from '../../../test/fixtures/fake-feature-toggle-client-store'; import FakeProjectStore from '../../../test/fixtures/fake-project-store'; import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store'; diff --git a/src/test/fixtures/fake-feature-strategies-store.ts b/src/lib/features/feature-toggle/fakes/fake-feature-strategies-store.ts similarity index 97% rename from src/test/fixtures/fake-feature-strategies-store.ts rename to src/lib/features/feature-toggle/fakes/fake-feature-strategies-store.ts index 63718f8e3e35..688a84f1c2aa 100644 --- a/src/test/fixtures/fake-feature-strategies-store.ts +++ b/src/lib/features/feature-toggle/fakes/fake-feature-strategies-store.ts @@ -6,10 +6,10 @@ import { IFeatureToggleQuery, IFeatureStrategy, FeatureToggle, -} from '../../lib/types/model'; -import NotFoundError from '../../lib/error/notfound-error'; -import { IFeatureStrategiesStore } from '../../lib/types/stores/feature-strategies-store'; -import { IFeatureProjectUserParams } from '../../lib/routes/admin-api/project/project-features'; +} from '../../../types/model'; +import NotFoundError from '../../../error/notfound-error'; +import { IFeatureStrategiesStore } from '../types/feature-toggle-strategies-store-type'; +import { IFeatureProjectUserParams } from '../feature-toggle-controller'; interface ProjectEnvironment { projectName: string; diff --git a/src/test/fixtures/fake-feature-toggle-store.ts b/src/lib/features/feature-toggle/fakes/fake-feature-toggle-store.ts similarity index 96% rename from src/test/fixtures/fake-feature-toggle-store.ts rename to src/lib/features/feature-toggle/fakes/fake-feature-toggle-store.ts index bb6835592eda..3f4aa478a976 100644 --- a/src/test/fixtures/fake-feature-toggle-store.ts +++ b/src/lib/features/feature-toggle/fakes/fake-feature-toggle-store.ts @@ -1,16 +1,16 @@ import { IFeatureToggleQuery, IFeatureToggleStore, -} from '../../lib/types/stores/feature-toggle-store'; -import NotFoundError from '../../lib/error/notfound-error'; +} from '../types/feature-toggle-store-type'; +import NotFoundError from '../../../error/notfound-error'; import { FeatureToggle, FeatureToggleDTO, IFeatureEnvironment, IVariant, } from 'lib/types/model'; -import { LastSeenInput } from '../../lib/services/client-metrics/last-seen/last-seen-service'; -import { EnvironmentFeatureNames } from '../../lib/db/feature-toggle-store'; +import { LastSeenInput } from '../../../services/client-metrics/last-seen/last-seen-service'; +import { EnvironmentFeatureNames } from '../feature-toggle-store'; export default class FakeFeatureToggleStore implements IFeatureToggleStore { features: FeatureToggle[] = []; diff --git a/src/lib/routes/admin-api/project/project-features.ts b/src/lib/features/feature-toggle/feature-toggle-controller.ts similarity index 98% rename from src/lib/routes/admin-api/project/project-features.ts rename to src/lib/features/feature-toggle/feature-toggle-controller.ts index 8441f56eddc5..9ad0b3aeb9cb 100644 --- a/src/lib/routes/admin-api/project/project-features.ts +++ b/src/lib/features/feature-toggle/feature-toggle-controller.ts @@ -1,6 +1,6 @@ import { Request, Response } from 'express'; import { applyPatch, Operation } from 'fast-json-patch'; -import Controller from '../../controller'; +import Controller from '../../routes/controller'; import { CREATE_FEATURE, CREATE_FEATURE_STRATEGY, @@ -14,10 +14,10 @@ import { UPDATE_FEATURE, UPDATE_FEATURE_ENVIRONMENT, UPDATE_FEATURE_STRATEGY, -} from '../../../types'; -import { Logger } from '../../../logger'; -import { extractUsername } from '../../../util'; -import { IAuthRequest } from '../../unleash-types'; +} from '../../types'; +import { Logger } from '../../logger'; +import { extractUsername } from '../../util'; +import { IAuthRequest } from '../../routes/unleash-types'; import { AdminFeaturesQuerySchema, BulkToggleFeaturesSchema, @@ -40,19 +40,16 @@ import { TagSchema, UpdateFeatureSchema, UpdateFeatureStrategySchema, -} from '../../../openapi'; +} from '../../openapi'; import { FeatureTagService, FeatureToggleService, OpenApiService, -} from '../../../services'; -import { querySchema } from '../../../schema/feature-schema'; -import { BatchStaleSchema } from '../../../openapi/spec/batch-stale-schema'; -import { - TransactionCreator, - UnleashTransaction, -} from '../../../db/transaction'; -import { BadDataError } from '../../../error'; +} from '../../services'; +import { querySchema } from '../../schema/feature-schema'; +import { BatchStaleSchema } from '../../openapi/spec/batch-stale-schema'; +import { TransactionCreator, UnleashTransaction } from '../../db/transaction'; +import { BadDataError } from '../../error'; interface FeatureStrategyParams { projectId: string; diff --git a/src/lib/services/feature-toggle-service.ts b/src/lib/features/feature-toggle/feature-toggle-service.ts similarity index 98% rename from src/lib/services/feature-toggle-service.ts rename to src/lib/features/feature-toggle/feature-toggle-service.ts index b365c3949f6e..8cc11fa80730 100644 --- a/src/lib/services/feature-toggle-service.ts +++ b/src/lib/features/feature-toggle/feature-toggle-service.ts @@ -45,36 +45,36 @@ import { StrategyIds, Unsaved, WeightType, -} from '../types'; -import { Logger } from '../logger'; +} from '../../types'; +import { Logger } from '../../logger'; import { ForbiddenError, FOREIGN_KEY_VIOLATION, OperationDeniedError, PatternError, PermissionError, -} from '../error'; -import BadDataError from '../error/bad-data-error'; -import NameExistsError from '../error/name-exists-error'; -import InvalidOperationError from '../error/invalid-operation-error'; +} from '../../error'; +import BadDataError from '../../error/bad-data-error'; +import NameExistsError from '../../error/name-exists-error'; +import InvalidOperationError from '../../error/invalid-operation-error'; import { constraintSchema, featureMetadataSchema, nameSchema, variantsArraySchema, -} from '../schema/feature-schema'; -import NotFoundError from '../error/notfound-error'; +} from '../../schema/feature-schema'; +import NotFoundError from '../../error/notfound-error'; import { FeatureConfigurationClient, IFeatureStrategiesStore, -} from '../types/stores/feature-strategies-store'; +} from './types/feature-toggle-strategies-store-type'; import { DATE_OPERATORS, DEFAULT_ENV, NUM_OPERATORS, SEMVER_OPERATORS, STRING_OPERATORS, -} from '../util'; +} from '../../util'; import { applyPatch, deepClone, Operation } from 'fast-json-patch'; import { validateDate, @@ -82,24 +82,24 @@ import { validateNumber, validateSemver, validateString, -} from '../util/validators/constraint-types'; +} from '../../util/validators/constraint-types'; import { IContextFieldStore } from 'lib/types/stores/context-field-store'; import { SetStrategySortOrderSchema } from 'lib/openapi/spec/set-strategy-sort-order-schema'; import { getDefaultStrategy, getProjectDefaultStrategy, -} from '../features/playground/feature-evaluator/helpers'; -import { AccessService } from './access-service'; -import { User } from '../server-impl'; -import { IFeatureProjectUserParams } from '../routes/admin-api/project/project-features'; -import { unique } from '../util/unique'; +} from '../playground/feature-evaluator/helpers'; +import { AccessService } from '../../services/access-service'; +import { User } from '../../server-impl'; +import { IFeatureProjectUserParams } from './feature-toggle-controller'; +import { unique } from '../../util/unique'; import { ISegmentService } from 'lib/segments/segment-service-interface'; -import { IChangeRequestAccessReadModel } from '../features/change-request-access-service/change-request-access-read-model'; -import { checkFeatureFlagNamesAgainstPattern } from '../features/feature-naming-pattern/feature-naming-validation'; -import { IPrivateProjectChecker } from '../features/private-project/privateProjectCheckerType'; -import { IDependentFeaturesReadModel } from '../features/dependent-features/dependent-features-read-model-type'; -import EventService from './event-service'; -import { DependentFeaturesService } from '../features/dependent-features/dependent-features-service'; +import { IChangeRequestAccessReadModel } from '../change-request-access-service/change-request-access-read-model'; +import { checkFeatureFlagNamesAgainstPattern } from '../feature-naming-pattern/feature-naming-validation'; +import { IPrivateProjectChecker } from '../private-project/privateProjectCheckerType'; +import { IDependentFeaturesReadModel } from '../dependent-features/dependent-features-read-model-type'; +import EventService from '../../services/event-service'; +import { DependentFeaturesService } from '../dependent-features/dependent-features-service'; interface IFeatureContext { featureName: string; diff --git a/src/lib/db/feature-toggle-store.ts b/src/lib/features/feature-toggle/feature-toggle-store.ts similarity index 96% rename from src/lib/db/feature-toggle-store.ts rename to src/lib/features/feature-toggle/feature-toggle-store.ts index 3d96050f32eb..a066e439d5b7 100644 --- a/src/lib/db/feature-toggle-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-store.ts @@ -1,14 +1,14 @@ import { Knex } from 'knex'; import EventEmitter from 'events'; -import metricsHelper from '../util/metrics-helper'; -import { DB_TIME } from '../metric-events'; -import NotFoundError from '../error/notfound-error'; -import { Logger, LogProvider } from '../logger'; -import { FeatureToggle, FeatureToggleDTO, IVariant } from '../types/model'; -import { IFeatureToggleStore } from '../types/stores/feature-toggle-store'; -import { Db } from './db'; -import { LastSeenInput } from '../services/client-metrics/last-seen/last-seen-service'; -import { NameExistsError } from '../error'; +import metricsHelper from '../../util/metrics-helper'; +import { DB_TIME } from '../../metric-events'; +import NotFoundError from '../../error/notfound-error'; +import { Logger, LogProvider } from '../../logger'; +import { FeatureToggle, FeatureToggleDTO, IVariant } from '../../types/model'; +import { IFeatureToggleStore } from './types/feature-toggle-store-type'; +import { Db } from '../../db/db'; +import { LastSeenInput } from '../../services/client-metrics/last-seen/last-seen-service'; +import { NameExistsError } from '../../error'; export type EnvironmentFeatureNames = { [key: string]: string[] }; diff --git a/src/lib/db/feature-strategy-store.ts b/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts similarity index 98% rename from src/lib/db/feature-strategy-store.ts rename to src/lib/features/feature-toggle/feature-toggle-strategies-store.ts index a5584c215e20..65808ba36ecd 100644 --- a/src/lib/db/feature-strategy-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts @@ -1,10 +1,10 @@ import { Knex } from 'knex'; import EventEmitter from 'events'; import { v4 as uuidv4 } from 'uuid'; -import metricsHelper from '../util/metrics-helper'; -import { DB_TIME } from '../metric-events'; -import { Logger, LogProvider } from '../logger'; -import NotFoundError from '../error/notfound-error'; +import metricsHelper from '../../util/metrics-helper'; +import { DB_TIME } from '../../metric-events'; +import { Logger, LogProvider } from '../../logger'; +import NotFoundError from '../../error/notfound-error'; import { FeatureToggleWithEnvironment, IConstraint, @@ -19,11 +19,11 @@ import { ITag, PartialDeep, PartialSome, -} from '../types'; +} from '../../types'; import FeatureToggleStore from './feature-toggle-store'; -import { ensureStringValue, mapValues } from '../util'; -import { IFeatureProjectUserParams } from '../routes/admin-api/project/project-features'; -import { Db } from './db'; +import { ensureStringValue, mapValues } from '../../util'; +import { IFeatureProjectUserParams } from './feature-toggle-controller'; +import { Db } from '../../db/db'; import Raw = Knex.Raw; const COLUMNS = [ diff --git a/src/lib/routes/admin-api/feature.ts b/src/lib/features/feature-toggle/legacy/feature-toggle-legacy-controller.ts similarity index 92% rename from src/lib/routes/admin-api/feature.ts rename to src/lib/features/feature-toggle/legacy/feature-toggle-legacy-controller.ts index e83e36f23be8..9b364c6cbf9d 100644 --- a/src/lib/routes/admin-api/feature.ts +++ b/src/lib/features/feature-toggle/legacy/feature-toggle-legacy-controller.ts @@ -1,35 +1,35 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { Request, Response } from 'express'; -import Controller from '../controller'; -import { extractUsername } from '../../util/extract-user'; -import { NONE, UPDATE_FEATURE } from '../../types/permissions'; -import { IUnleashConfig } from '../../types/option'; -import { IUnleashServices } from '../../types'; -import FeatureToggleService from '../../services/feature-toggle-service'; -import { featureSchema, querySchema } from '../../schema/feature-schema'; -import { IFeatureToggleQuery } from '../../types/model'; -import FeatureTagService from '../../services/feature-tag-service'; -import { IAuthRequest } from '../unleash-types'; -import { DEFAULT_ENV } from '../../util/constants'; +import Controller from '../../../routes/controller'; +import { extractUsername } from '../../../util/extract-user'; +import { NONE, UPDATE_FEATURE } from '../../../types/permissions'; +import { IUnleashConfig } from '../../../types/option'; +import { IUnleashServices } from '../../../types'; +import FeatureToggleService from '../feature-toggle-service'; +import { featureSchema, querySchema } from '../../../schema/feature-schema'; +import { IFeatureToggleQuery } from '../../../types/model'; +import FeatureTagService from '../../../services/feature-tag-service'; +import { IAuthRequest } from '../../../routes/unleash-types'; +import { DEFAULT_ENV } from '../../../util/constants'; import { featuresSchema, FeaturesSchema, -} from '../../openapi/spec/features-schema'; -import { TagSchema } from '../../openapi/spec/tag-schema'; -import { TagsSchema } from '../../openapi/spec/tags-schema'; -import { serializeDates } from '../../types/serialize-dates'; -import { OpenApiService } from '../../services/openapi-service'; -import { createRequestSchema } from '../../openapi/util/create-request-schema'; +} from '../../../openapi/spec/features-schema'; +import { TagSchema } from '../../../openapi/spec/tag-schema'; +import { TagsSchema } from '../../../openapi/spec/tags-schema'; +import { serializeDates } from '../../../types/serialize-dates'; +import { OpenApiService } from '../../../services/openapi-service'; +import { createRequestSchema } from '../../../openapi/util/create-request-schema'; import { createResponseSchema, resourceCreatedResponseSchema, -} from '../../openapi/util/create-response-schema'; +} from '../../../openapi/util/create-response-schema'; import { emptyResponse, getStandardResponses, -} from '../../openapi/util/standard-responses'; -import { UpdateTagsSchema } from '../../openapi/spec/update-tags-schema'; -import { ValidateFeatureSchema } from '../../openapi/spec/validate-feature-schema'; +} from '../../../openapi/util/standard-responses'; +import { UpdateTagsSchema } from '../../../openapi/spec/update-tags-schema'; +import { ValidateFeatureSchema } from '../../../openapi/spec/validate-feature-schema'; const version = 1; diff --git a/src/test/e2e/services/feature-toggle-service-v2.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts similarity index 96% rename from src/test/e2e/services/feature-toggle-service-v2.e2e.test.ts rename to src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts index c9b04d50bec2..38576fe8f5bc 100644 --- a/src/test/e2e/services/feature-toggle-service-v2.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-service.e2e.test.ts @@ -1,30 +1,23 @@ -import FeatureToggleService from '../../../lib/services/feature-toggle-service'; -import { createTestConfig } from '../../config/test-config'; -import dbInit from '../helpers/database-init'; -import { DEFAULT_ENV } from '../../../lib/util'; -import { FeatureStrategySchema } from '../../../lib/openapi'; -import User from '../../../lib/types/user'; +import FeatureToggleService from '../feature-toggle-service'; +import { createTestConfig } from '../../../../test/config/test-config'; +import dbInit from '../../../../test/e2e/helpers/database-init'; +import { DEFAULT_ENV } from '../../../util'; +import { FeatureStrategySchema } from '../../../openapi'; +import User from '../../../types/user'; import { IConstraint, IUnleashStores, IVariant, SKIP_CHANGE_REQUEST, -} from '../../../lib/types'; -import EnvironmentService from '../../../lib/services/environment-service'; -import { - ForbiddenError, - PatternError, - PermissionError, -} from '../../../lib/error'; -import { ISegmentService } from '../../../lib/segments/segment-service-interface'; -import { - createFeatureToggleService, - createSegmentService, -} from '../../../lib/features'; +} from '../../../types'; +import EnvironmentService from '../../../services/environment-service'; +import { ForbiddenError, PatternError, PermissionError } from '../../../error'; +import { ISegmentService } from '../../../segments/segment-service-interface'; +import { createFeatureToggleService, createSegmentService } from '../..'; import { insertFeatureEnvironmentsLastSeen, insertLastSeenAt, -} from '../api/admin/project/projects.e2e.test'; +} from '../../../../test/e2e/api/admin/project/projects.e2e.test'; let stores: IUnleashStores; let db; diff --git a/src/test/e2e/stores/feature-toggle-store.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts similarity index 98% rename from src/test/e2e/stores/feature-toggle-store.e2e.test.ts rename to src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts index 99f1c134469b..beeca94b467d 100644 --- a/src/test/e2e/stores/feature-toggle-store.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts @@ -1,6 +1,6 @@ -import dbInit from '../helpers/database-init'; -import getLogger from '../../fixtures/no-logger'; -import { FeatureToggleDTO, IFeatureToggleStore } from '../../../lib/types'; +import dbInit from '../../../../test/e2e/helpers/database-init'; +import getLogger from '../../../../test/fixtures/no-logger'; +import { FeatureToggleDTO, IFeatureToggleStore } from '../../../types'; let stores; let db; diff --git a/src/test/e2e/stores/feature-strategies-store.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts similarity index 92% rename from src/test/e2e/stores/feature-strategies-store.e2e.test.ts rename to src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts index af21e48eca55..7deb1d9785da 100644 --- a/src/test/e2e/stores/feature-strategies-store.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts @@ -1,7 +1,7 @@ -import { IFeatureStrategiesStore } from 'lib/types/stores/feature-strategies-store'; -import { IFeatureToggleStore } from 'lib/types/stores/feature-toggle-store'; -import dbInit from '../helpers/database-init'; -import getLogger from '../../fixtures/no-logger'; +import { IFeatureStrategiesStore } from 'lib/features/feature-toggle/types/feature-toggle-strategies-store-type'; +import { IFeatureToggleStore } from 'lib/features/feature-toggle/types/feature-toggle-store-type'; +import dbInit from '../../../../test/e2e/helpers/database-init'; +import getLogger from '../../../../test/fixtures/no-logger'; let stores; let db; diff --git a/src/test/e2e/api/admin/project/features.auth.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts similarity index 88% rename from src/test/e2e/api/admin/project/features.auth.e2e.test.ts rename to src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts index 9468138bfc5f..669e4405b3b2 100644 --- a/src/test/e2e/api/admin/project/features.auth.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts @@ -1,8 +1,11 @@ -import dbInit, { ITestDb } from '../../../helpers/database-init'; -import { IUnleashTest, setupAppWithAuth } from '../../../helpers/test-helper'; -import getLogger from '../../../../fixtures/no-logger'; -import { DEFAULT_ENV } from '../../../../../lib/util'; -import { RoleName, CREATE_FEATURE_STRATEGY } from '../../../../../lib/types'; +import dbInit, { ITestDb } from '../../../../test/e2e/helpers/database-init'; +import { + IUnleashTest, + setupAppWithAuth, +} from '../../../../test/e2e/helpers/test-helper'; +import getLogger from '../../../../test/fixtures/no-logger'; +import { DEFAULT_ENV } from '../../../util'; +import { RoleName, CREATE_FEATURE_STRATEGY } from '../../../types'; let app: IUnleashTest; let db: ITestDb; diff --git a/src/test/e2e/api/admin/project/features.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggles.e2e.test.ts similarity index 99% rename from src/test/e2e/api/admin/project/features.e2e.test.ts rename to src/lib/features/feature-toggle/tests/feature-toggles.e2e.test.ts index cee7163a1743..493464d31919 100644 --- a/src/test/e2e/api/admin/project/features.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggles.e2e.test.ts @@ -1,10 +1,10 @@ -import dbInit, { ITestDb } from '../../../helpers/database-init'; +import dbInit, { ITestDb } from '../../../../test/e2e/helpers/database-init'; import { IUnleashTest, setupAppWithCustomConfig, -} from '../../../helpers/test-helper'; -import getLogger from '../../../../fixtures/no-logger'; -import { DEFAULT_ENV } from '../../../../../lib/util/constants'; +} from '../../../../test/e2e/helpers/test-helper'; +import getLogger from '../../../../test/fixtures/no-logger'; +import { DEFAULT_ENV } from '../../../util/constants'; import { FEATURE_ENVIRONMENT_DISABLED, FEATURE_ENVIRONMENT_ENABLED, @@ -12,22 +12,22 @@ import { FEATURE_STALE_OFF, FEATURE_STALE_ON, FEATURE_STRATEGY_REMOVE, -} from '../../../../../lib/types/events'; -import ApiUser from '../../../../../lib/types/api-user'; -import { ApiTokenType } from '../../../../../lib/types/models/api-token'; -import IncompatibleProjectError from '../../../../../lib/error/incompatible-project-error'; +} from '../../../types/events'; +import ApiUser from '../../../types/api-user'; +import { ApiTokenType } from '../../../types/models/api-token'; +import IncompatibleProjectError from '../../../error/incompatible-project-error'; import { IStrategyConfig, IVariant, RoleName, WeightType, -} from '../../../../../lib/types/model'; +} from '../../../types/model'; import { v4 as uuidv4 } from 'uuid'; import supertest from 'supertest'; -import { randomId } from '../../../../../lib/util/random-id'; -import { DEFAULT_PROJECT } from '../../../../../lib/types'; +import { randomId } from '../../../util/random-id'; +import { DEFAULT_PROJECT } from '../../../types'; import { FeatureStrategySchema, SetStrategySortOrderSchema } from 'lib/openapi'; -import { ForbiddenError } from '../../../../../lib/error'; +import { ForbiddenError } from '../../../error'; let app: IUnleashTest; let db: ITestDb; diff --git a/src/lib/types/stores/feature-toggle-store.ts b/src/lib/features/feature-toggle/types/feature-toggle-store-type.ts similarity index 90% rename from src/lib/types/stores/feature-toggle-store.ts rename to src/lib/features/feature-toggle/types/feature-toggle-store-type.ts index 67bc103898b0..7e2a1749f7ae 100644 --- a/src/lib/types/stores/feature-toggle-store.ts +++ b/src/lib/features/feature-toggle/types/feature-toggle-store-type.ts @@ -1,6 +1,10 @@ -import { FeatureToggle, FeatureToggleDTO, IVariant } from '../model'; -import { Store } from './store'; -import { LastSeenInput } from '../../services/client-metrics/last-seen/last-seen-service'; +import { + FeatureToggle, + FeatureToggleDTO, + IVariant, +} from '../../../types/model'; +import { Store } from '../../../types/stores/store'; +import { LastSeenInput } from '../../../services/client-metrics/last-seen/last-seen-service'; export interface IFeatureToggleQuery { archived: boolean; diff --git a/src/lib/types/stores/feature-strategies-store.ts b/src/lib/features/feature-toggle/types/feature-toggle-strategies-store-type.ts similarity index 93% rename from src/lib/types/stores/feature-strategies-store.ts rename to src/lib/features/feature-toggle/types/feature-toggle-strategies-store-type.ts index ac84251be5d1..00059dc89598 100644 --- a/src/lib/types/stores/feature-strategies-store.ts +++ b/src/lib/features/feature-toggle/types/feature-toggle-strategies-store-type.ts @@ -5,9 +5,9 @@ import { IFeatureStrategy, IStrategyConfig, IVariant, -} from '../model'; -import { Store } from './store'; -import { IFeatureProjectUserParams } from '../../routes/admin-api/project/project-features'; +} from '../../../types/model'; +import { Store } from '../../../types/stores/store'; +import { IFeatureProjectUserParams } from '../feature-toggle-controller'; export interface FeatureConfigurationClient { name: string; diff --git a/src/lib/features/instance-stats/instance-stats-service.ts b/src/lib/features/instance-stats/instance-stats-service.ts index 532466a0bcc0..8b6890c776b0 100644 --- a/src/lib/features/instance-stats/instance-stats-service.ts +++ b/src/lib/features/instance-stats/instance-stats-service.ts @@ -8,7 +8,7 @@ import { } from '../../types/stores'; import { IContextFieldStore } from '../../types/stores/context-field-store'; import { IEnvironmentStore } from '../../types/stores/environment-store'; -import { IFeatureToggleStore } from '../../types/stores/feature-toggle-store'; +import { IFeatureToggleStore } from '../feature-toggle/types/feature-toggle-store-type'; import { IGroupStore } from '../../types/stores/group-store'; import { IProjectStore } from '../../types/stores/project-store'; import { IStrategyStore } from '../../types/stores/strategy-store'; diff --git a/src/lib/features/playground/offline-unleash-client.ts b/src/lib/features/playground/offline-unleash-client.ts index 63115fae1281..20d0229d3822 100644 --- a/src/lib/features/playground/offline-unleash-client.ts +++ b/src/lib/features/playground/offline-unleash-client.ts @@ -1,6 +1,6 @@ import { SdkContextSchema } from 'lib/openapi/spec/sdk-context-schema'; import { InMemStorageProvider, FeatureEvaluator } from './feature-evaluator'; -import { FeatureConfigurationClient } from 'lib/types/stores/feature-strategies-store'; +import { FeatureConfigurationClient } from 'lib/features/feature-toggle/types/feature-toggle-strategies-store-type'; import { Segment } from './feature-evaluator/strategy/strategy'; import { ISegment } from 'lib/types/model'; import { serializeDates } from '../../types/serialize-dates'; diff --git a/src/lib/features/playground/playground-service.ts b/src/lib/features/playground/playground-service.ts index 8679d2d76c00..4b29f1d7888a 100644 --- a/src/lib/features/playground/playground-service.ts +++ b/src/lib/features/playground/playground-service.ts @@ -1,4 +1,4 @@ -import FeatureToggleService from '../../services/feature-toggle-service'; +import FeatureToggleService from '../feature-toggle/feature-toggle-service'; import { SdkContextSchema } from 'lib/openapi/spec/sdk-context-schema'; import { IUnleashServices } from 'lib/types/services'; import { ALL } from '../../types/models/api-token'; @@ -12,7 +12,7 @@ import { FeatureStrategiesEvaluationResult, } from 'lib/features/playground/feature-evaluator/client'; import { ISegmentService } from 'lib/segments/segment-service-interface'; -import { FeatureConfigurationClient } from '../../types/stores/feature-strategies-store'; +import { FeatureConfigurationClient } from '../feature-toggle/types/feature-toggle-strategies-store-type'; import { generateObjectCombinations } from './generateObjectCombinations'; import groupBy from 'lodash.groupby'; import { omitKeys } from '../../util'; diff --git a/src/lib/features/project/createProjectService.ts b/src/lib/features/project/createProjectService.ts index e6e230ee6e76..01758643d1a1 100644 --- a/src/lib/features/project/createProjectService.ts +++ b/src/lib/features/project/createProjectService.ts @@ -13,7 +13,7 @@ import { import FakeGroupStore from '../../../test/fixtures/fake-group-store'; import FakeEventStore from '../../../test/fixtures/fake-event-store'; import ProjectStore from '../../db/project-store'; -import FeatureToggleStore from '../../db/feature-toggle-store'; +import FeatureToggleStore from '../feature-toggle/feature-toggle-store'; import FeatureTypeStore from '../../db/feature-type-store'; import { FeatureEnvironmentStore } from '../../db/feature-environment-store'; import ProjectStatsStore from '../../db/project-stats-store'; @@ -28,7 +28,7 @@ import { import { FavoriteFeaturesStore } from '../../db/favorite-features-store'; import { FavoriteProjectsStore } from '../../db/favorite-projects-store'; import FakeProjectStore from '../../../test/fixtures/fake-project-store'; -import FakeFeatureToggleStore from '../../../test/fixtures/fake-feature-toggle-store'; +import FakeFeatureToggleStore from '../feature-toggle/fakes/fake-feature-toggle-store'; import FakeFeatureTypeStore from '../../../test/fixtures/fake-feature-type-store'; import FakeEnvironmentStore from '../../../test/fixtures/fake-environment-store'; import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store'; diff --git a/src/lib/features/segment/createSegmentService.ts b/src/lib/features/segment/createSegmentService.ts index f558437084a3..7534d9f5bf52 100644 --- a/src/lib/features/segment/createSegmentService.ts +++ b/src/lib/features/segment/createSegmentService.ts @@ -3,10 +3,10 @@ import EventStore from '../../db/event-store'; import { EventService, SegmentService } from '../../services'; import FakeEventStore from '../../../test/fixtures/fake-event-store'; import { ISegmentService } from '../../segments/segment-service-interface'; -import FeatureStrategiesStore from '../../db/feature-strategy-store'; +import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store'; import SegmentStore from '../../db/segment-store'; import FakeSegmentStore from '../../../test/fixtures/fake-segment-store'; -import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store'; +import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store'; import { createChangeRequestAccessReadModel, createFakeChangeRequestAccessService, diff --git a/src/lib/middleware/rbac-middleware.test.ts b/src/lib/middleware/rbac-middleware.test.ts index a49e7283bc79..53dfbe08a4d1 100644 --- a/src/lib/middleware/rbac-middleware.test.ts +++ b/src/lib/middleware/rbac-middleware.test.ts @@ -4,8 +4,8 @@ import * as perms from '../types/permissions'; import { IUnleashConfig } from '../types/option'; import { createTestConfig } from '../../test/config/test-config'; import ApiUser from '../types/api-user'; -import { IFeatureToggleStore } from '../types/stores/feature-toggle-store'; -import FakeFeatureToggleStore from '../../test/fixtures/fake-feature-toggle-store'; +import { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type'; +import FakeFeatureToggleStore from '../features/feature-toggle/fakes/fake-feature-toggle-store'; import { ApiTokenType } from '../types/models/api-token'; let config: IUnleashConfig; diff --git a/src/lib/routes/admin-api/archive.ts b/src/lib/routes/admin-api/archive.ts index 9ca110160d65..92345cc47946 100644 --- a/src/lib/routes/admin-api/archive.ts +++ b/src/lib/routes/admin-api/archive.ts @@ -4,7 +4,7 @@ import { IUnleashServices } from '../../types'; import Controller from '../controller'; import { extractUsername } from '../../util/extract-user'; import { DELETE_FEATURE, NONE, UPDATE_FEATURE } from '../../types/permissions'; -import FeatureToggleService from '../../services/feature-toggle-service'; +import FeatureToggleService from '../../features/feature-toggle/feature-toggle-service'; import { IAuthRequest } from '../unleash-types'; import { featuresSchema, diff --git a/src/lib/routes/admin-api/constraints.ts b/src/lib/routes/admin-api/constraints.ts index 53c03e6d71c8..c6a7518a6347 100644 --- a/src/lib/routes/admin-api/constraints.ts +++ b/src/lib/routes/admin-api/constraints.ts @@ -1,5 +1,5 @@ import { Request, Response } from 'express'; -import FeatureToggleService from '../../services/feature-toggle-service'; +import FeatureToggleService from '../../features/feature-toggle/feature-toggle-service'; import { IUnleashConfig } from '../../types/option'; import { IUnleashServices } from '../../types'; import { NONE } from '../../types/permissions'; diff --git a/src/lib/routes/admin-api/index.ts b/src/lib/routes/admin-api/index.ts index cfba7ddbf510..929272f35a97 100644 --- a/src/lib/routes/admin-api/index.ts +++ b/src/lib/routes/admin-api/index.ts @@ -1,6 +1,6 @@ import Controller from '../controller'; import { IUnleashServices, IUnleashConfig } from '../../types'; -import FeatureController from './feature'; +import FeatureController from '../../features/feature-toggle/legacy/feature-toggle-legacy-controller'; import { FeatureTypeController } from './feature-type'; import ArchiveController from './archive'; import StrategyController from './strategy'; diff --git a/src/lib/routes/admin-api/project/api-token.ts b/src/lib/routes/admin-api/project/api-token.ts index 2cdc1ff013ca..9fcca526edd4 100644 --- a/src/lib/routes/admin-api/project/api-token.ts +++ b/src/lib/routes/admin-api/project/api-token.ts @@ -151,7 +151,6 @@ export class ProjectApiTokenController extends Controller { const { projectId } = req.params; const project = await this.projectService.getProject(projectId); // Validates that the project exists - console.log('project', project); const projectTokens = await this.accessibleTokens(user, projectId); this.openApiService.respondWithValidation( 200, diff --git a/src/lib/routes/admin-api/project/index.ts b/src/lib/routes/admin-api/project/index.ts index 15f5d837004f..402e9d7bbaf1 100644 --- a/src/lib/routes/admin-api/project/index.ts +++ b/src/lib/routes/admin-api/project/index.ts @@ -8,7 +8,7 @@ import { NONE, serializeDates, } from '../../../types'; -import ProjectFeaturesController from './project-features'; +import ProjectFeaturesController from '../../../features/feature-toggle/feature-toggle-controller'; import EnvironmentsController from './environments'; import ProjectHealthReport from './health-report'; import ProjectService from '../../../services/project-service'; diff --git a/src/lib/routes/admin-api/project/project-archive.ts b/src/lib/routes/admin-api/project/project-archive.ts index d9809d06b56c..4ffd55d6c87c 100644 --- a/src/lib/routes/admin-api/project/project-archive.ts +++ b/src/lib/routes/admin-api/project/project-archive.ts @@ -9,7 +9,7 @@ import { import { Logger } from '../../../logger'; import { extractUsername } from '../../../util/extract-user'; import { DELETE_FEATURE } from '../../../types/permissions'; -import FeatureToggleService from '../../../services/feature-toggle-service'; +import FeatureToggleService from '../../../features/feature-toggle/feature-toggle-service'; import { IAuthRequest } from '../../unleash-types'; import { OpenApiService } from '../../../services/openapi-service'; import { diff --git a/src/lib/routes/admin-api/project/variants.ts b/src/lib/routes/admin-api/project/variants.ts index 2f62494f39c0..667b70b00b05 100644 --- a/src/lib/routes/admin-api/project/variants.ts +++ b/src/lib/routes/admin-api/project/variants.ts @@ -1,4 +1,4 @@ -import FeatureToggleService from '../../../services/feature-toggle-service'; +import FeatureToggleService from '../../../features/feature-toggle/feature-toggle-service'; import { Logger } from '../../../logger'; import Controller from '../../controller'; import { IUnleashConfig } from '../../../types/option'; diff --git a/src/lib/routes/client-api/feature.ts b/src/lib/routes/client-api/feature.ts index 79713876b419..8203f13149a3 100644 --- a/src/lib/routes/client-api/feature.ts +++ b/src/lib/routes/client-api/feature.ts @@ -4,7 +4,7 @@ import { Response } from 'express'; import hashSum from 'hash-sum'; import Controller from '../controller'; import { IClientSegment, IUnleashConfig, IUnleashServices } from '../../types'; -import FeatureToggleService from '../../services/feature-toggle-service'; +import FeatureToggleService from '../../features/feature-toggle/feature-toggle-service'; import { Logger } from '../../logger'; import { querySchema } from '../../schema/feature-schema'; import { IFeatureToggleQuery } from '../../types/model'; @@ -12,7 +12,7 @@ import NotFoundError from '../../error/notfound-error'; import { IAuthRequest } from '../unleash-types'; import ApiUser from '../../types/api-user'; import { ALL, isAllProjects } from '../../types/models/api-token'; -import { FeatureConfigurationClient } from '../../types/stores/feature-strategies-store'; +import { FeatureConfigurationClient } from '../../features/feature-toggle/types/feature-toggle-strategies-store-type'; import { ClientSpecService } from '../../services/client-spec-service'; import { OpenApiService } from '../../services/openapi-service'; import { NONE } from '../../types/permissions'; diff --git a/src/lib/services/addon-service.ts b/src/lib/services/addon-service.ts index 72e4af9ec0c3..c802adb80220 100644 --- a/src/lib/services/addon-service.ts +++ b/src/lib/services/addon-service.ts @@ -4,7 +4,7 @@ import { getAddons, IAddonProviders } from '../addons'; import * as events from '../types/events'; import { addonSchema } from './addon-schema'; import NameExistsError from '../error/name-exists-error'; -import { IFeatureToggleStore } from '../types/stores/feature-toggle-store'; +import { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type'; import { Logger } from '../logger'; import TagTypeService from './tag-type-service'; import { IAddon, IAddonDto, IAddonStore } from '../types/stores/addon-store'; diff --git a/src/lib/services/client-metrics/instance-service.ts b/src/lib/services/client-metrics/instance-service.ts index f819dc486e47..9af1bb41935d 100644 --- a/src/lib/services/client-metrics/instance-service.ts +++ b/src/lib/services/client-metrics/instance-service.ts @@ -7,7 +7,7 @@ import { IClientApplication, IClientApplicationsStore, } from '../../types/stores/client-applications-store'; -import { IFeatureToggleStore } from '../../types/stores/feature-toggle-store'; +import { IFeatureToggleStore } from '../../features/feature-toggle/types/feature-toggle-store-type'; import { IStrategyStore } from '../../types/stores/strategy-store'; import { IClientInstanceStore } from '../../types/stores/client-instance-store'; import { IApplicationQuery } from '../../types/query'; diff --git a/src/lib/services/client-metrics/last-seen/createLastSeenService.ts b/src/lib/services/client-metrics/last-seen/createLastSeenService.ts index 1dac8feeeb48..938a4d707842 100644 --- a/src/lib/services/client-metrics/last-seen/createLastSeenService.ts +++ b/src/lib/services/client-metrics/last-seen/createLastSeenService.ts @@ -1,5 +1,5 @@ -import FakeFeatureToggleStore from '../../../../test/fixtures/fake-feature-toggle-store'; -import FeatureToggleStore from '../../../db/feature-toggle-store'; +import FakeFeatureToggleStore from '../../../features/feature-toggle/fakes/fake-feature-toggle-store'; +import FeatureToggleStore from '../../../features/feature-toggle/feature-toggle-store'; import { Db, IUnleashConfig } from '../../../server-impl'; import { FakeLastSeenStore } from './fake-last-seen-store'; import { LastSeenService } from './last-seen-service'; diff --git a/src/lib/services/feature-service-potentially-stale.test.ts b/src/lib/services/feature-service-potentially-stale.test.ts index 551074aecad3..51ec34a7af71 100644 --- a/src/lib/services/feature-service-potentially-stale.test.ts +++ b/src/lib/services/feature-service-potentially-stale.test.ts @@ -5,7 +5,7 @@ import { IUnleashStores, } from '../types'; import { createTestConfig } from '../../test/config/test-config'; -import FeatureToggleService from './feature-toggle-service'; +import FeatureToggleService from '../features/feature-toggle/feature-toggle-service'; import { AccessService } from './access-service'; import { IChangeRequestAccessReadModel } from 'lib/features/change-request-access-service/change-request-access-read-model'; import { ISegmentService } from 'lib/segments/segment-service-interface'; diff --git a/src/lib/services/index.ts b/src/lib/services/index.ts index bf67b8efdfc2..b825d15ab022 100644 --- a/src/lib/services/index.ts +++ b/src/lib/services/index.ts @@ -21,7 +21,7 @@ import ResetTokenService from './reset-token-service'; import SettingService from './setting-service'; import SessionService from './session-service'; import UserFeedbackService from './user-feedback-service'; -import FeatureToggleService from './feature-toggle-service'; +import FeatureToggleService from '../features/feature-toggle/feature-toggle-service'; import EnvironmentService from './environment-service'; import FeatureTagService from './feature-tag-service'; import ProjectHealthService from './project-health-service'; diff --git a/src/lib/services/project-health-service.ts b/src/lib/services/project-health-service.ts index ab85391ce113..f03fbe5ff703 100644 --- a/src/lib/services/project-health-service.ts +++ b/src/lib/services/project-health-service.ts @@ -2,7 +2,7 @@ import { IUnleashStores } from '../types/stores'; import { IUnleashConfig } from '../types/option'; import { Logger } from '../logger'; import type { IProject, IProjectHealthReport } from '../types/model'; -import type { IFeatureToggleStore } from '../types/stores/feature-toggle-store'; +import type { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type'; import type { IFeatureTypeStore } from '../types/stores/feature-type-store'; import type { IProjectStore } from '../types/stores/project-store'; import ProjectService from './project-service'; diff --git a/src/lib/services/project-service.ts b/src/lib/services/project-service.ts index 46eb3946416d..02ddceda739e 100644 --- a/src/lib/services/project-service.ts +++ b/src/lib/services/project-service.ts @@ -50,7 +50,7 @@ import { IProjectAccessModel, IRoleDescriptor, } from '../types/stores/access-store'; -import FeatureToggleService from './feature-toggle-service'; +import FeatureToggleService from '../features/feature-toggle/feature-toggle-service'; import IncompatibleProjectError from '../error/incompatible-project-error'; import ProjectWithoutOwnerError from '../error/project-without-owner-error'; import { arraysHaveSameItems } from '../util'; diff --git a/src/lib/services/segment-service.ts b/src/lib/services/segment-service.ts index fc040c54fcd3..a5fd7a52d575 100644 --- a/src/lib/services/segment-service.ts +++ b/src/lib/services/segment-service.ts @@ -16,7 +16,7 @@ import { SEGMENT_UPDATED, } from '../types/events'; import User from '../types/user'; -import { IFeatureStrategiesStore } from '../types/stores/feature-strategies-store'; +import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type'; import BadDataError from '../error/bad-data-error'; import { ISegmentService } from '../segments/segment-service-interface'; import { PermissionError } from '../error'; diff --git a/src/lib/services/state-service.ts b/src/lib/services/state-service.ts index 4906f083e442..7eb2642b4b3c 100644 --- a/src/lib/services/state-service.ts +++ b/src/lib/services/state-service.ts @@ -40,8 +40,8 @@ import { IProjectStore } from '../types/stores/project-store'; import { ITagType, ITagTypeStore } from '../types/stores/tag-type-store'; import { ITagStore } from '../types/stores/tag-store'; import { IStrategy, IStrategyStore } from '../types/stores/strategy-store'; -import { IFeatureToggleStore } from '../types/stores/feature-toggle-store'; -import { IFeatureStrategiesStore } from '../types/stores/feature-strategies-store'; +import { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type'; +import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type'; import { IEnvironmentStore } from '../types/stores/environment-store'; import { IFeatureEnvironmentStore } from '../types/stores/feature-environment-store'; import { IUnleashStores } from '../types/stores'; diff --git a/src/lib/types/services.ts b/src/lib/types/services.ts index 3efe05d19be2..10df0ed3686d 100644 --- a/src/lib/types/services.ts +++ b/src/lib/types/services.ts @@ -18,7 +18,7 @@ import HealthService from '../services/health-service'; import SettingService from '../services/setting-service'; import SessionService from '../services/session-service'; import UserFeedbackService from '../services/user-feedback-service'; -import FeatureToggleService from '../services/feature-toggle-service'; +import FeatureToggleService from '../features/feature-toggle/feature-toggle-service'; import EnvironmentService from '../services/environment-service'; import FeatureTagService from '../services/feature-tag-service'; import ProjectHealthService from '../services/project-health-service'; diff --git a/src/lib/types/stores.ts b/src/lib/types/stores.ts index ad78f996e905..e696cc704df6 100644 --- a/src/lib/types/stores.ts +++ b/src/lib/types/stores.ts @@ -4,7 +4,7 @@ import { IFeatureTypeStore } from './stores/feature-type-store'; import { IStrategyStore } from './stores/strategy-store'; import { IClientApplicationsStore } from './stores/client-applications-store'; import { IClientInstanceStore } from './stores/client-instance-store'; -import { IFeatureToggleStore } from './stores/feature-toggle-store'; +import { IFeatureToggleStore } from '../features/feature-toggle/types/feature-toggle-store-type'; import { IContextFieldStore } from './stores/context-field-store'; import { ISettingStore } from './stores/settings-store'; import { ISessionStore } from './stores/session-store'; @@ -18,7 +18,7 @@ import { IApiTokenStore } from './stores/api-token-store'; import { IResetTokenStore } from './stores/reset-token-store'; import { IUserFeedbackStore } from './stores/user-feedback-store'; import { IFeatureEnvironmentStore } from './stores/feature-environment-store'; -import { IFeatureStrategiesStore } from './stores/feature-strategies-store'; +import { IFeatureStrategiesStore } from '../features/feature-toggle/types/feature-toggle-strategies-store-type'; import { IEnvironmentStore } from './stores/environment-store'; import { IFeatureToggleClientStore } from './stores/feature-toggle-client-store'; import { IClientMetricsStoreV2 } from './stores/client-metrics-store-v2'; diff --git a/src/test/e2e/services/playground-service.test.ts b/src/test/e2e/services/playground-service.test.ts index cc0d31a89b60..b9974fdc93cb 100644 --- a/src/test/e2e/services/playground-service.test.ts +++ b/src/test/e2e/services/playground-service.test.ts @@ -11,7 +11,7 @@ import fc from 'fast-check'; import { createTestConfig } from '../../config/test-config'; import dbInit, { ITestDb } from '../helpers/database-init'; import { IUnleashStores } from '../../../lib/types/stores'; -import FeatureToggleService from '../../../lib/services/feature-toggle-service'; +import FeatureToggleService from '../../../lib/features/feature-toggle/feature-toggle-service'; import { FeatureToggle, ISegment, WeightType } from '../../../lib/types/model'; import { PlaygroundFeatureSchema } from '../../../lib/openapi/spec/playground-feature-schema'; import { offlineUnleashClientNode } from '../../../lib/features/playground/offline-unleash-client.test'; diff --git a/src/test/e2e/services/project-service.e2e.test.ts b/src/test/e2e/services/project-service.e2e.test.ts index d539ecab860b..8ade603eca42 100644 --- a/src/test/e2e/services/project-service.e2e.test.ts +++ b/src/test/e2e/services/project-service.e2e.test.ts @@ -1,6 +1,6 @@ import dbInit, { ITestDb } from '../helpers/database-init'; import getLogger from '../../fixtures/no-logger'; -import FeatureToggleService from '../../../lib/services/feature-toggle-service'; +import FeatureToggleService from '../../../lib/features/feature-toggle/feature-toggle-service'; import ProjectService from '../../../lib/services/project-service'; import { AccessService } from '../../../lib/services/access-service'; import { MOVE_FEATURE_TOGGLE } from '../../../lib/types/permissions'; diff --git a/src/test/e2e/stores/feature-environment-store.e2e.test.ts b/src/test/e2e/stores/feature-environment-store.e2e.test.ts index 0420e39fd19e..3c91e0a40697 100644 --- a/src/test/e2e/stores/feature-environment-store.e2e.test.ts +++ b/src/test/e2e/stores/feature-environment-store.e2e.test.ts @@ -2,7 +2,7 @@ import { IUnleashStores } from '../../../lib/types'; import dbInit from '../helpers/database-init'; import getLogger from '../../fixtures/no-logger'; import { IFeatureEnvironmentStore } from '../../../lib/types/stores/feature-environment-store'; -import { IFeatureToggleStore } from '../../../lib/types/stores/feature-toggle-store'; +import { IFeatureToggleStore } from '../../../lib/features/feature-toggle/types/feature-toggle-store-type'; import { IEnvironmentStore } from '../../../lib/types/stores/environment-store'; let db; diff --git a/src/test/e2e/stores/feature-tag-store.e2e.test.ts b/src/test/e2e/stores/feature-tag-store.e2e.test.ts index ede33d8677f7..0728b9b8ff9b 100644 --- a/src/test/e2e/stores/feature-tag-store.e2e.test.ts +++ b/src/test/e2e/stores/feature-tag-store.e2e.test.ts @@ -1,5 +1,5 @@ import { IFeatureTagStore } from 'lib/types/stores/feature-tag-store'; -import { IFeatureToggleStore } from 'lib/types/stores/feature-toggle-store'; +import { IFeatureToggleStore } from 'lib/features/feature-toggle/types/feature-toggle-store-type'; import dbInit from '../helpers/database-init'; import getLogger from '../../fixtures/no-logger'; import NotFoundError from '../../../lib/error/notfound-error'; diff --git a/src/test/fixtures/store.ts b/src/test/fixtures/store.ts index bfa2015695b2..e692aaa40bca 100644 --- a/src/test/fixtures/store.ts +++ b/src/test/fixtures/store.ts @@ -1,7 +1,7 @@ -import FakeFeatureStrategiesStore from './fake-feature-strategies-store'; +import FakeFeatureStrategiesStore from '../../lib/features/feature-toggle/fakes/fake-feature-strategies-store'; import FakeClientInstanceStore from './fake-client-instance-store'; import FakeClientApplicationsStore from './fake-client-applications-store'; -import FakeFeatureToggleStore from './fake-feature-toggle-store'; +import FakeFeatureToggleStore from '../../lib/features/feature-toggle/fakes/fake-feature-toggle-store'; import FakeTagStore from './fake-tag-store'; import FakeTagTypeStore from './fake-tag-type-store'; import FakeEventStore from './fake-event-store';