diff --git a/src/lib/util/feature-evaluator/client.ts b/src/lib/features/playground/feature-evaluator/client.ts similarity index 98% rename from src/lib/util/feature-evaluator/client.ts rename to src/lib/features/playground/feature-evaluator/client.ts index 9b58bff7f4..ab9e9477a2 100644 --- a/src/lib/util/feature-evaluator/client.ts +++ b/src/lib/features/playground/feature-evaluator/client.ts @@ -10,7 +10,7 @@ import { import { Context } from './context'; import { SegmentForEvaluation } from './strategy/strategy'; import { PlaygroundStrategySchema } from 'lib/openapi/spec/playground-strategy-schema'; -import { playgroundStrategyEvaluation } from '../../openapi/spec/playground-strategy-schema'; +import { playgroundStrategyEvaluation } from '../../../openapi/spec/playground-strategy-schema'; export type StrategyEvaluationResult = Pick< PlaygroundStrategySchema, diff --git a/src/lib/util/feature-evaluator/constraint.ts b/src/lib/features/playground/feature-evaluator/constraint.ts similarity index 100% rename from src/lib/util/feature-evaluator/constraint.ts rename to src/lib/features/playground/feature-evaluator/constraint.ts diff --git a/src/lib/util/feature-evaluator/context.ts b/src/lib/features/playground/feature-evaluator/context.ts similarity index 100% rename from src/lib/util/feature-evaluator/context.ts rename to src/lib/features/playground/feature-evaluator/context.ts diff --git a/src/lib/util/feature-evaluator/feature-evaluator.ts b/src/lib/features/playground/feature-evaluator/feature-evaluator.ts similarity index 100% rename from src/lib/util/feature-evaluator/feature-evaluator.ts rename to src/lib/features/playground/feature-evaluator/feature-evaluator.ts diff --git a/src/lib/util/feature-evaluator/feature.ts b/src/lib/features/playground/feature-evaluator/feature.ts similarity index 100% rename from src/lib/util/feature-evaluator/feature.ts rename to src/lib/features/playground/feature-evaluator/feature.ts diff --git a/src/lib/util/feature-evaluator/helpers.ts b/src/lib/features/playground/feature-evaluator/helpers.ts similarity index 97% rename from src/lib/util/feature-evaluator/helpers.ts rename to src/lib/features/playground/feature-evaluator/helpers.ts index aff23e7d0a..a7dc628ba6 100644 --- a/src/lib/util/feature-evaluator/helpers.ts +++ b/src/lib/features/playground/feature-evaluator/helpers.ts @@ -1,4 +1,4 @@ -import { IStrategyConfig } from '../../types'; +import { IStrategyConfig } from '../../../types'; import { FeatureStrategiesEvaluationResult } from './client'; import { Context } from './context'; diff --git a/src/lib/util/feature-evaluator/index.ts b/src/lib/features/playground/feature-evaluator/index.ts similarity index 90% rename from src/lib/util/feature-evaluator/index.ts rename to src/lib/features/playground/feature-evaluator/index.ts index 32560d0fb9..0783a2443a 100644 --- a/src/lib/util/feature-evaluator/index.ts +++ b/src/lib/features/playground/feature-evaluator/index.ts @@ -5,6 +5,6 @@ import { ClientFeaturesResponse } from './feature'; import InMemStorageProvider from './repository/storage-provider-in-mem'; // exports -export { Strategy } from './strategy/index'; +export { Strategy } from './strategy'; export { Context, Variant, FeatureEvaluator, InMemStorageProvider }; export type { ClientFeaturesResponse, FeatureEvaluatorConfig }; diff --git a/src/lib/util/feature-evaluator/repository/bootstrap-provider.ts b/src/lib/features/playground/feature-evaluator/repository/bootstrap-provider.ts similarity index 100% rename from src/lib/util/feature-evaluator/repository/bootstrap-provider.ts rename to src/lib/features/playground/feature-evaluator/repository/bootstrap-provider.ts diff --git a/src/lib/util/feature-evaluator/repository/index.ts b/src/lib/features/playground/feature-evaluator/repository/index.ts similarity index 100% rename from src/lib/util/feature-evaluator/repository/index.ts rename to src/lib/features/playground/feature-evaluator/repository/index.ts diff --git a/src/lib/util/feature-evaluator/repository/storage-provider-in-mem.ts b/src/lib/features/playground/feature-evaluator/repository/storage-provider-in-mem.ts similarity index 100% rename from src/lib/util/feature-evaluator/repository/storage-provider-in-mem.ts rename to src/lib/features/playground/feature-evaluator/repository/storage-provider-in-mem.ts diff --git a/src/lib/util/feature-evaluator/repository/storage-provider.ts b/src/lib/features/playground/feature-evaluator/repository/storage-provider.ts similarity index 100% rename from src/lib/util/feature-evaluator/repository/storage-provider.ts rename to src/lib/features/playground/feature-evaluator/repository/storage-provider.ts diff --git a/src/lib/util/feature-evaluator/strategy/application-hostname-strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/application-hostname-strategy.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/application-hostname-strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/application-hostname-strategy.ts diff --git a/src/lib/util/feature-evaluator/strategy/default-strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/default-strategy.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/default-strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/default-strategy.ts diff --git a/src/lib/util/feature-evaluator/strategy/flexible-rollout-strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/flexible-rollout-strategy.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/flexible-rollout-strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/flexible-rollout-strategy.ts diff --git a/src/lib/util/feature-evaluator/strategy/gradual-rollout-random.ts b/src/lib/features/playground/feature-evaluator/strategy/gradual-rollout-random.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/gradual-rollout-random.ts rename to src/lib/features/playground/feature-evaluator/strategy/gradual-rollout-random.ts diff --git a/src/lib/util/feature-evaluator/strategy/gradual-rollout-session-id.ts b/src/lib/features/playground/feature-evaluator/strategy/gradual-rollout-session-id.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/gradual-rollout-session-id.ts rename to src/lib/features/playground/feature-evaluator/strategy/gradual-rollout-session-id.ts diff --git a/src/lib/util/feature-evaluator/strategy/gradual-rollout-user-id.ts b/src/lib/features/playground/feature-evaluator/strategy/gradual-rollout-user-id.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/gradual-rollout-user-id.ts rename to src/lib/features/playground/feature-evaluator/strategy/gradual-rollout-user-id.ts diff --git a/src/lib/util/feature-evaluator/strategy/index.ts b/src/lib/features/playground/feature-evaluator/strategy/index.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/index.ts rename to src/lib/features/playground/feature-evaluator/strategy/index.ts diff --git a/src/lib/util/feature-evaluator/strategy/remote-address-strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/remote-address-strategy.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/remote-address-strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/remote-address-strategy.ts diff --git a/src/lib/util/feature-evaluator/strategy/strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/strategy.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/strategy.ts diff --git a/src/lib/util/feature-evaluator/strategy/unknown-strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/unknown-strategy.ts similarity index 92% rename from src/lib/util/feature-evaluator/strategy/unknown-strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/unknown-strategy.ts index 90ca87a389..5277101483 100644 --- a/src/lib/util/feature-evaluator/strategy/unknown-strategy.ts +++ b/src/lib/features/playground/feature-evaluator/strategy/unknown-strategy.ts @@ -1,4 +1,4 @@ -import { playgroundStrategyEvaluation } from '../../../openapi/spec/playground-strategy-schema'; +import { playgroundStrategyEvaluation } from '../../../../openapi/spec/playground-strategy-schema'; import { StrategyEvaluationResult } from '../client'; import { Constraint } from '../constraint'; import { Context } from '../context'; diff --git a/src/lib/util/feature-evaluator/strategy/user-with-id-strategy.ts b/src/lib/features/playground/feature-evaluator/strategy/user-with-id-strategy.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/user-with-id-strategy.ts rename to src/lib/features/playground/feature-evaluator/strategy/user-with-id-strategy.ts diff --git a/src/lib/util/feature-evaluator/strategy/util.ts b/src/lib/features/playground/feature-evaluator/strategy/util.ts similarity index 100% rename from src/lib/util/feature-evaluator/strategy/util.ts rename to src/lib/features/playground/feature-evaluator/strategy/util.ts diff --git a/src/lib/util/feature-evaluator/variant.ts b/src/lib/features/playground/feature-evaluator/variant.ts similarity index 100% rename from src/lib/util/feature-evaluator/variant.ts rename to src/lib/features/playground/feature-evaluator/variant.ts diff --git a/src/lib/util/offline-unleash-client.test.ts b/src/lib/features/playground/offline-unleash-client.test.ts similarity index 99% rename from src/lib/util/offline-unleash-client.test.ts rename to src/lib/features/playground/offline-unleash-client.test.ts index 607cbe729b..a6da34b7a4 100644 --- a/src/lib/util/offline-unleash-client.test.ts +++ b/src/lib/features/playground/offline-unleash-client.test.ts @@ -9,7 +9,7 @@ import { InMemStorageProvider as InMemStorageProviderNode, } from 'unleash-client'; import { once } from 'events'; -import { playgroundStrategyEvaluation } from '../openapi/spec/playground-strategy-schema'; +import { playgroundStrategyEvaluation } from '../../openapi/spec/playground-strategy-schema'; export const offlineUnleashClientNode = async ({ features, diff --git a/src/lib/util/offline-unleash-client.ts b/src/lib/features/playground/offline-unleash-client.ts similarity index 97% rename from src/lib/util/offline-unleash-client.ts rename to src/lib/features/playground/offline-unleash-client.ts index c17a19b947..d8051bcab6 100644 --- a/src/lib/util/offline-unleash-client.ts +++ b/src/lib/features/playground/offline-unleash-client.ts @@ -3,7 +3,7 @@ import { InMemStorageProvider, FeatureEvaluator } from './feature-evaluator'; import { FeatureConfigurationClient } from 'lib/types/stores/feature-strategies-store'; import { Segment } from './feature-evaluator/strategy/strategy'; import { ISegment } from 'lib/types/model'; -import { serializeDates } from '../../lib/types/serialize-dates'; +import { serializeDates } from '../../types/serialize-dates'; import { Operator } from './feature-evaluator/constraint'; import { FeatureInterface } from 'unleash-client/lib/feature'; import { PayloadType } from 'unleash-client'; diff --git a/src/lib/services/playground-service.ts b/src/lib/features/playground/playground-service.ts similarity index 89% rename from src/lib/services/playground-service.ts rename to src/lib/features/playground/playground-service.ts index f7798c36b0..76ad00132a 100644 --- a/src/lib/services/playground-service.ts +++ b/src/lib/features/playground/playground-service.ts @@ -1,13 +1,13 @@ -import FeatureToggleService from './feature-toggle-service'; +import FeatureToggleService from '../../services/feature-toggle-service'; import { SdkContextSchema } from 'lib/openapi/spec/sdk-context-schema'; import { IUnleashServices } from 'lib/types/services'; -import { ALL } from '../../lib/types/models/api-token'; +import { ALL } from '../../types/models/api-token'; import { PlaygroundFeatureSchema } from 'lib/openapi/spec/playground-feature-schema'; -import { Logger } from '../logger'; +import { Logger } from '../../logger'; import { IUnleashConfig } from 'lib/types'; -import { offlineUnleashClient } from '../util/offline-unleash-client'; -import { FeatureInterface } from 'lib/util/feature-evaluator/feature'; -import { FeatureStrategiesEvaluationResult } from 'lib/util/feature-evaluator/client'; +import { offlineUnleashClient } from './offline-unleash-client'; +import { FeatureInterface } from 'lib/features/playground/feature-evaluator/feature'; +import { FeatureStrategiesEvaluationResult } from 'lib/features/playground/feature-evaluator/client'; import { ISegmentService } from 'lib/segments/segment-service-interface'; export class PlaygroundService { diff --git a/src/lib/routes/admin-api/playground.test.ts b/src/lib/features/playground/playground.test.ts similarity index 94% rename from src/lib/routes/admin-api/playground.test.ts rename to src/lib/features/playground/playground.test.ts index da594a5065..bc6d0a3d93 100644 --- a/src/lib/routes/admin-api/playground.test.ts +++ b/src/lib/features/playground/playground.test.ts @@ -10,9 +10,9 @@ import getApp from '../../app'; import { playgroundRequestSchema, PlaygroundRequestSchema, -} from '../../../lib/openapi/spec/playground-request-schema'; +} from '../../openapi/spec/playground-request-schema'; -import { generate as generateRequest } from '../../../lib/openapi/spec/playground-request-schema.test'; +import { generate as generateRequest } from '../../openapi/spec/playground-request-schema.test'; import { clientFeatures } from '../../../test/arbitraries.test'; async function getSetup() { diff --git a/src/lib/routes/admin-api/playground.ts b/src/lib/features/playground/playground.ts similarity index 83% rename from src/lib/routes/admin-api/playground.ts rename to src/lib/features/playground/playground.ts index c9fb48203b..c0c9e0fc05 100644 --- a/src/lib/routes/admin-api/playground.ts +++ b/src/lib/features/playground/playground.ts @@ -2,18 +2,18 @@ import { Request, Response } from 'express'; import { IUnleashConfig } from '../../types/option'; import { IUnleashServices } from '../../types/services'; import { NONE } from '../../types/permissions'; -import Controller from '../controller'; +import Controller from '../../routes/controller'; import { OpenApiService } from '../../services/openapi-service'; import { createResponseSchema } from '../../openapi/util/create-response-schema'; import { endpointDescriptions } from '../../openapi/endpoint-descriptions'; -import { getStandardResponses } from '../../../lib/openapi/util/standard-responses'; -import { createRequestSchema } from '../../../lib/openapi/util/create-request-schema'; +import { getStandardResponses } from '../../openapi/util/standard-responses'; +import { createRequestSchema } from '../../openapi/util/create-request-schema'; import { PlaygroundResponseSchema, playgroundResponseSchema, -} from '../../../lib/openapi/spec/playground-response-schema'; -import { PlaygroundRequestSchema } from '../../../lib/openapi/spec/playground-request-schema'; -import { PlaygroundService } from '../../../lib/services/playground-service'; +} from '../../openapi/spec/playground-response-schema'; +import { PlaygroundRequestSchema } from '../../openapi/spec/playground-request-schema'; +import { PlaygroundService } from './playground-service'; export default class PlaygroundController extends Controller { private openApiService: OpenApiService; diff --git a/src/lib/proxy/proxy-repository.ts b/src/lib/proxy/proxy-repository.ts index 821c11cebd..9c2f49995d 100644 --- a/src/lib/proxy/proxy-repository.ts +++ b/src/lib/proxy/proxy-repository.ts @@ -7,7 +7,7 @@ import { IUnleashConfig, IUnleashServices, IUnleashStores } from '../types'; import { mapFeaturesForClient, mapSegmentsForClient, -} from '../util/offline-unleash-client'; +} from '../features/playground/offline-unleash-client'; import { ALL_ENVS, ALL_PROJECTS } from '../util/constants'; import { UnleashEvents } from 'unleash-client'; import { Logger } from '../logger'; diff --git a/src/lib/routes/admin-api/index.ts b/src/lib/routes/admin-api/index.ts index d4ea29dfc6..1a2d38dc31 100644 --- a/src/lib/routes/admin-api/index.ts +++ b/src/lib/routes/admin-api/index.ts @@ -5,7 +5,7 @@ import { FeatureTypeController } from './feature-type'; import ArchiveController from './archive'; import StrategyController from './strategy'; import EventController from './event'; -import PlaygroundController from './playground'; +import PlaygroundController from '../../features/playground/playground'; import MetricsController from './metrics'; import UserController from './user/user'; import ConfigController from './config'; diff --git a/src/lib/services/feature-toggle-service.ts b/src/lib/services/feature-toggle-service.ts index 3dd81ea7a7..8796d2f462 100644 --- a/src/lib/services/feature-toggle-service.ts +++ b/src/lib/services/feature-toggle-service.ts @@ -76,7 +76,7 @@ import { SetStrategySortOrderSchema } from 'lib/openapi/spec/set-strategy-sort-o import { getDefaultStrategy, getProjectDefaultStrategy, -} from '../util/feature-evaluator/helpers'; +} from '../features/playground/feature-evaluator/helpers'; import { AccessService } from './access-service'; import { User } from '../server-impl'; import NoAccessError from '../error/no-access-error'; diff --git a/src/lib/services/index.ts b/src/lib/services/index.ts index 81af0381be..075747b166 100644 --- a/src/lib/services/index.ts +++ b/src/lib/services/index.ts @@ -29,7 +29,7 @@ import UserSplashService from './user-splash-service'; import { SegmentService } from './segment-service'; import { OpenApiService } from './openapi-service'; import { ClientSpecService } from './client-spec-service'; -import { PlaygroundService } from './playground-service'; +import { PlaygroundService } from '../features/playground/playground-service'; import { GroupService } from './group-service'; import { ProxyService } from './proxy-service'; import EdgeService from './edge-service'; diff --git a/src/lib/types/services.ts b/src/lib/types/services.ts index 3db0b22f53..9c9597bd72 100644 --- a/src/lib/types/services.ts +++ b/src/lib/types/services.ts @@ -26,7 +26,7 @@ import ClientMetricsServiceV2 from '../services/client-metrics/metrics-service-v import UserSplashService from '../services/user-splash-service'; import { OpenApiService } from '../services/openapi-service'; import { ClientSpecService } from '../services/client-spec-service'; -import { PlaygroundService } from 'lib/services/playground-service'; +import { PlaygroundService } from 'lib/features/playground/playground-service'; import { GroupService } from '../services/group-service'; import { ProxyService } from '../services/proxy-service'; import EdgeService from '../services/edge-service'; diff --git a/src/lib/util/index.ts b/src/lib/util/index.ts index f1ffabae8b..be4ac8aa64 100644 --- a/src/lib/util/index.ts +++ b/src/lib/util/index.ts @@ -29,4 +29,4 @@ export * from './validateJsonString'; export * from './arraysHaveSameItems'; export * from './constantTimeCompare'; export * from './collapseHourlyMetrics'; -export * from './offline-unleash-client'; +export * from '../features/playground/offline-unleash-client'; diff --git a/src/test/e2e/services/playground-service.test.ts b/src/test/e2e/services/playground-service.test.ts index c456d64a75..58a94aa721 100644 --- a/src/test/e2e/services/playground-service.test.ts +++ b/src/test/e2e/services/playground-service.test.ts @@ -1,4 +1,4 @@ -import { PlaygroundService } from '../../../lib/services/playground-service'; +import { PlaygroundService } from '../../../lib/features/playground/playground-service'; import { clientFeaturesAndSegments, commonISOTimestamp, @@ -12,7 +12,7 @@ import FeatureToggleService from '../../../lib/services/feature-toggle-service'; import { SegmentService } from '../../../lib/services/segment-service'; import { FeatureToggle, ISegment, WeightType } from '../../../lib/types/model'; import { PlaygroundFeatureSchema } from '../../../lib/openapi/spec/playground-feature-schema'; -import { offlineUnleashClientNode } from '../../../lib/util/offline-unleash-client.test'; +import { offlineUnleashClientNode } from '../../../lib/features/playground/offline-unleash-client.test'; import { ClientFeatureSchema } from 'lib/openapi/spec/client-feature-schema'; import { SdkContextSchema } from 'lib/openapi/spec/sdk-context-schema'; import { SegmentSchema } from 'lib/openapi/spec/segment-schema';