unleash-server 5.1.8 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/create-config.js +5 -2
- package/dist/lib/create-config.js.map +1 -1
- package/dist/lib/db/access-store.d.ts +2 -1
- package/dist/lib/db/access-store.js +17 -3
- package/dist/lib/db/access-store.js.map +1 -1
- package/dist/lib/db/client-metrics-store-v2.js +19 -30
- package/dist/lib/db/client-metrics-store-v2.js.map +1 -1
- package/dist/lib/db/context-field-store.d.ts +4 -1
- package/dist/lib/db/context-field-store.js +44 -14
- package/dist/lib/db/context-field-store.js.map +1 -1
- package/dist/lib/db/environment-store.d.ts +1 -0
- package/dist/lib/db/environment-store.js +6 -0
- package/dist/lib/db/environment-store.js.map +1 -1
- package/dist/lib/db/event-store.js +2 -1
- package/dist/lib/db/event-store.js.map +1 -1
- package/dist/lib/db/feature-strategy-store.d.ts +2 -0
- package/dist/lib/db/feature-strategy-store.js +25 -0
- package/dist/lib/db/feature-strategy-store.js.map +1 -1
- package/dist/lib/db/feature-strategy-store.test.js +75 -0
- package/dist/lib/db/feature-strategy-store.test.js.map +1 -0
- package/dist/lib/db/group-store.d.ts +1 -1
- package/dist/lib/db/group-store.js +2 -2
- package/dist/lib/db/group-store.js.map +1 -1
- package/dist/lib/db/index.js +2 -2
- package/dist/lib/db/index.js.map +1 -1
- package/dist/lib/db/project-store.js +2 -1
- package/dist/lib/db/project-store.js.map +1 -1
- package/dist/lib/db/role-store.js +2 -2
- package/dist/lib/db/role-store.js.map +1 -1
- package/dist/lib/db/segment-store.d.ts +6 -2
- package/dist/lib/db/segment-store.js +27 -6
- package/dist/lib/db/segment-store.js.map +1 -1
- package/dist/lib/error/no-access-error.d.ts +3 -2
- package/dist/lib/error/no-access-error.js +10 -4
- package/dist/lib/error/no-access-error.js.map +1 -1
- package/dist/lib/error/unleash-error.test.js +8 -2
- package/dist/lib/error/unleash-error.test.js.map +1 -1
- package/dist/lib/features/access/createAccessService.js +5 -5
- package/dist/lib/features/access/createAccessService.js.map +1 -1
- package/dist/lib/features/export-import-toggles/createExportImportService.js +4 -2
- package/dist/lib/features/export-import-toggles/createExportImportService.js.map +1 -1
- package/dist/lib/features/export-import-toggles/export-import-api-usage.test.d.ts +1 -0
- package/dist/lib/features/export-import-toggles/export-import-api-usage.test.js +69 -0
- package/dist/lib/features/export-import-toggles/export-import-api-usage.test.js.map +1 -0
- package/dist/lib/features/export-import-toggles/export-import-controller.js +5 -1
- package/dist/lib/features/export-import-toggles/export-import-controller.js.map +1 -1
- package/dist/lib/features/export-import-toggles/export-import-service.js +7 -2
- package/dist/lib/features/export-import-toggles/export-import-service.js.map +1 -1
- package/dist/lib/features/feature-toggle/createFeatureToggleService.js +4 -4
- package/dist/lib/features/feature-toggle/createFeatureToggleService.js.map +1 -1
- package/dist/lib/features/playground/advanced-playground.test.d.ts +1 -0
- package/dist/lib/features/playground/advanced-playground.test.js +238 -0
- package/dist/lib/features/playground/advanced-playground.test.js.map +1 -0
- package/dist/lib/{util → features/playground}/feature-evaluator/client.d.ts +3 -2
- package/dist/lib/{util → features/playground}/feature-evaluator/client.js +1 -1
- package/dist/lib/features/playground/feature-evaluator/client.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/constraint.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/context.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/feature-evaluator.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/feature.js.map +1 -0
- package/dist/lib/{util → features/playground}/feature-evaluator/helpers.d.ts +1 -1
- package/dist/lib/features/playground/feature-evaluator/helpers.js.map +1 -0
- package/dist/lib/{util → features/playground}/feature-evaluator/index.d.ts +1 -1
- package/dist/lib/{util → features/playground}/feature-evaluator/index.js +2 -2
- package/dist/lib/features/playground/feature-evaluator/index.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/repository/bootstrap-provider.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/repository/index.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/repository/storage-provider-in-mem.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/repository/storage-provider.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/application-hostname-strategy.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/default-strategy.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/flexible-rollout-strategy.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/gradual-rollout-random.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/gradual-rollout-session-id.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/gradual-rollout-user-id.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/index.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/remote-address-strategy.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/strategy.js.map +1 -0
- package/dist/lib/{util → features/playground}/feature-evaluator/strategy/unknown-strategy.js +1 -1
- package/dist/lib/features/playground/feature-evaluator/strategy/unknown-strategy.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/user-with-id-strategy.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/strategy/util.js.map +1 -0
- package/dist/lib/features/playground/feature-evaluator/variant.js.map +1 -0
- package/dist/lib/features/playground/generateObjectCombinations.d.ts +7 -0
- package/dist/lib/features/playground/generateObjectCombinations.js +16 -0
- package/dist/lib/features/playground/generateObjectCombinations.js.map +1 -0
- package/dist/lib/features/playground/generateObjectCombinations.test.d.ts +1 -0
- package/dist/lib/features/playground/generateObjectCombinations.test.js +33 -0
- package/dist/lib/features/playground/generateObjectCombinations.test.js.map +1 -0
- package/dist/lib/{util → features/playground}/offline-unleash-client.js +2 -2
- package/dist/lib/features/playground/offline-unleash-client.js.map +1 -0
- package/dist/lib/{util → features/playground}/offline-unleash-client.test.js +1 -1
- package/dist/lib/features/playground/offline-unleash-client.test.js.map +1 -0
- package/dist/lib/features/playground/playground-service.d.ts +34 -0
- package/dist/lib/features/playground/playground-service.js +114 -0
- package/dist/lib/features/playground/playground-service.js.map +1 -0
- package/dist/lib/features/playground/playground-view-model.d.ts +4 -0
- package/dist/lib/features/playground/playground-view-model.js +49 -0
- package/dist/lib/features/playground/playground-view-model.js.map +1 -0
- package/dist/lib/features/playground/playground-view-model.test.d.ts +1 -0
- package/dist/lib/features/playground/playground-view-model.test.js +122 -0
- package/dist/lib/features/playground/playground-view-model.test.js.map +1 -0
- package/dist/lib/features/playground/playground.d.ts +16 -0
- package/dist/lib/features/playground/playground.js +78 -0
- package/dist/lib/features/playground/playground.js.map +1 -0
- package/dist/lib/features/playground/playground.test.d.ts +1 -0
- package/dist/lib/{routes/admin-api → features/playground}/playground.test.js +3 -2
- package/dist/lib/features/playground/playground.test.js.map +1 -0
- package/dist/lib/features/playground/validateQueryComplexity.d.ts +1 -0
- package/dist/lib/features/playground/validateQueryComplexity.js +15 -0
- package/dist/lib/features/playground/validateQueryComplexity.js.map +1 -0
- package/dist/lib/features/playground/validateQueryComplexity.test.d.ts +1 -0
- package/dist/lib/features/playground/validateQueryComplexity.test.js +19 -0
- package/dist/lib/features/playground/validateQueryComplexity.test.js.map +1 -0
- package/dist/lib/middleware/rbac-middleware.d.ts +1 -1
- package/dist/lib/middleware/rbac-middleware.js +7 -4
- package/dist/lib/middleware/rbac-middleware.js.map +1 -1
- package/dist/lib/middleware/rbac-middleware.test.js +8 -8
- package/dist/lib/middleware/rbac-middleware.test.js.map +1 -1
- package/dist/lib/openapi/endpoint-descriptions.d.ts +4 -0
- package/dist/lib/openapi/endpoint-descriptions.js +4 -0
- package/dist/lib/openapi/endpoint-descriptions.js.map +1 -1
- package/dist/lib/openapi/index.js +7 -0
- package/dist/lib/openapi/index.js.map +1 -1
- package/dist/lib/openapi/meta-schema-rules.test.js +16 -25
- package/dist/lib/openapi/meta-schema-rules.test.js.map +1 -1
- package/dist/lib/openapi/spec/advanced-playground-environment-feature-schema.d.ts +652 -0
- package/dist/lib/openapi/spec/advanced-playground-environment-feature-schema.js +146 -0
- package/dist/lib/openapi/spec/advanced-playground-environment-feature-schema.js.map +1 -0
- package/dist/lib/openapi/spec/advanced-playground-feature-schema.d.ts +1217 -0
- package/dist/lib/openapi/spec/advanced-playground-feature-schema.js +51 -0
- package/dist/lib/openapi/spec/advanced-playground-feature-schema.js.map +1 -0
- package/dist/lib/openapi/spec/advanced-playground-request-schema.d.ts +95 -0
- package/dist/lib/openapi/spec/advanced-playground-request-schema.js +49 -0
- package/dist/lib/openapi/spec/advanced-playground-request-schema.js.map +1 -0
- package/dist/lib/openapi/spec/advanced-playground-response-schema.d.ts +2560 -0
- package/dist/lib/openapi/spec/advanced-playground-response-schema.js +50 -0
- package/dist/lib/openapi/spec/advanced-playground-response-schema.js.map +1 -0
- package/dist/lib/openapi/spec/client-application-schema.d.ts +17 -0
- package/dist/lib/openapi/spec/client-application-schema.js +17 -0
- package/dist/lib/openapi/spec/client-application-schema.js.map +1 -1
- package/dist/lib/openapi/spec/client-feature-schema.d.ts +44 -13
- package/dist/lib/openapi/spec/client-feature-schema.js +17 -12
- package/dist/lib/openapi/spec/client-feature-schema.js.map +1 -1
- package/dist/lib/openapi/spec/client-features-query-schema.d.ts +12 -0
- package/dist/lib/openapi/spec/client-features-query-schema.js +12 -0
- package/dist/lib/openapi/spec/client-features-query-schema.js.map +1 -1
- package/dist/lib/openapi/spec/client-features-schema.d.ts +90 -14
- package/dist/lib/openapi/spec/client-features-schema.js +7 -0
- package/dist/lib/openapi/spec/client-features-schema.js.map +1 -1
- package/dist/lib/openapi/spec/client-features-schema.test.js +5 -12
- package/dist/lib/openapi/spec/client-features-schema.test.js.map +1 -1
- package/dist/lib/openapi/spec/client-metrics-schema.d.ts +1 -1
- package/dist/lib/openapi/spec/client-metrics-schema.js +1 -1
- package/dist/lib/openapi/spec/client-metrics-schema.js.map +1 -1
- package/dist/lib/openapi/spec/context-field-schema.d.ts +13 -0
- package/dist/lib/openapi/spec/context-field-schema.js +13 -0
- package/dist/lib/openapi/spec/context-field-schema.js.map +1 -1
- package/dist/lib/openapi/spec/context-field-strategies-schema.d.ts +43 -0
- package/dist/lib/openapi/spec/context-field-strategies-schema.js +51 -0
- package/dist/lib/openapi/spec/context-field-strategies-schema.js.map +1 -0
- package/dist/lib/openapi/spec/context-fields-schema.d.ts +13 -0
- package/dist/lib/openapi/spec/create-application-schema.d.ts +0 -1
- package/dist/lib/openapi/spec/create-application-schema.js +0 -1
- package/dist/lib/openapi/spec/create-application-schema.js.map +1 -1
- package/dist/lib/openapi/spec/export-result-schema.d.ts +137 -4
- package/dist/lib/openapi/spec/feature-environment-schema.d.ts +22 -1
- package/dist/lib/openapi/spec/feature-schema.d.ts +49 -2
- package/dist/lib/openapi/spec/feature-schema.test.js +1 -1
- package/dist/lib/openapi/spec/feature-schema.test.js.map +1 -1
- package/dist/lib/openapi/spec/feature-strategy-schema.d.ts +1 -1
- package/dist/lib/openapi/spec/feature-strategy-schema.js +1 -1
- package/dist/lib/openapi/spec/feature-strategy-schema.js.map +1 -1
- package/dist/lib/openapi/spec/feature-variants-schema.d.ts +26 -0
- package/dist/lib/openapi/spec/features-schema.d.ts +98 -4
- package/dist/lib/openapi/spec/health-check-schema.d.ts +3 -0
- package/dist/lib/openapi/spec/health-check-schema.js +3 -0
- package/dist/lib/openapi/spec/health-check-schema.js.map +1 -1
- package/dist/lib/openapi/spec/health-overview-schema.d.ts +105 -4
- package/dist/lib/openapi/spec/health-overview-schema.js +7 -0
- package/dist/lib/openapi/spec/health-overview-schema.js.map +1 -1
- package/dist/lib/openapi/spec/health-report-schema.d.ts +105 -4
- package/dist/lib/openapi/spec/import-toggles-schema.d.ts +274 -8
- package/dist/lib/openapi/spec/index.d.ts +3 -0
- package/dist/lib/openapi/spec/index.js +3 -0
- package/dist/lib/openapi/spec/index.js.map +1 -1
- package/dist/lib/openapi/spec/instance-admin-stats-schema.d.ts +65 -2
- package/dist/lib/openapi/spec/instance-admin-stats-schema.js +65 -2
- package/dist/lib/openapi/spec/instance-admin-stats-schema.js.map +1 -1
- package/dist/lib/openapi/spec/override-schema.d.ts +5 -0
- package/dist/lib/openapi/spec/override-schema.js +5 -0
- package/dist/lib/openapi/spec/override-schema.js.map +1 -1
- package/dist/lib/openapi/spec/password-schema.d.ts +3 -0
- package/dist/lib/openapi/spec/password-schema.js +3 -0
- package/dist/lib/openapi/spec/password-schema.js.map +1 -1
- package/dist/lib/openapi/spec/playground-feature-schema.d.ts +41 -1
- package/dist/lib/openapi/spec/playground-feature-schema.js +6 -1
- package/dist/lib/openapi/spec/playground-feature-schema.js.map +1 -1
- package/dist/lib/openapi/spec/playground-feature-schema.test.js +3 -0
- package/dist/lib/openapi/spec/playground-feature-schema.test.js.map +1 -1
- package/dist/lib/openapi/spec/playground-request-schema.d.ts +7 -1
- package/dist/lib/openapi/spec/playground-request-schema.js +1 -1
- package/dist/lib/openapi/spec/playground-request-schema.js.map +1 -1
- package/dist/lib/openapi/spec/playground-response-schema.d.ts +93 -3
- package/dist/lib/openapi/spec/playground-strategy-schema.d.ts +13 -1
- package/dist/lib/openapi/spec/playground-strategy-schema.js +13 -0
- package/dist/lib/openapi/spec/playground-strategy-schema.js.map +1 -1
- package/dist/lib/openapi/spec/profile-schema.d.ts +49 -2
- package/dist/lib/openapi/spec/project-overview-schema.d.ts +104 -4
- package/dist/lib/openapi/spec/project-overview-schema.js +6 -0
- package/dist/lib/openapi/spec/project-overview-schema.js.map +1 -1
- package/dist/lib/openapi/spec/push-variants-schema.d.ts +26 -0
- package/dist/lib/openapi/spec/sdk-context-schema.d.ts +6 -0
- package/dist/lib/openapi/spec/sdk-context-schema.js +14 -2
- package/dist/lib/openapi/spec/sdk-context-schema.js.map +1 -1
- package/dist/lib/openapi/spec/state-schema.d.ts +72 -4
- package/dist/lib/openapi/spec/variant-schema.d.ts +21 -0
- package/dist/lib/openapi/spec/variant-schema.js +13 -0
- package/dist/lib/openapi/spec/variant-schema.js.map +1 -1
- package/dist/lib/openapi/spec/variants-schema.d.ts +26 -0
- package/dist/lib/openapi/util/create-response-schema.d.ts +1 -0
- package/dist/lib/openapi/util/create-response-schema.js +7 -1
- package/dist/lib/openapi/util/create-response-schema.js.map +1 -1
- package/dist/lib/proxy/proxy-repository.js +1 -1
- package/dist/lib/proxy/proxy-repository.js.map +1 -1
- package/dist/lib/routes/admin-api/api-token.d.ts +2 -0
- package/dist/lib/routes/admin-api/api-token.js +120 -11
- package/dist/lib/routes/admin-api/api-token.js.map +1 -1
- package/dist/lib/routes/admin-api/context.d.ts +3 -0
- package/dist/lib/routes/admin-api/context.js +21 -0
- package/dist/lib/routes/admin-api/context.js.map +1 -1
- package/dist/lib/routes/admin-api/index.js +1 -1
- package/dist/lib/routes/admin-api/index.js.map +1 -1
- package/dist/lib/routes/admin-api/instance-admin.d.ts +3 -1
- package/dist/lib/routes/admin-api/instance-admin.js +41 -0
- package/dist/lib/routes/admin-api/instance-admin.js.map +1 -1
- package/dist/lib/routes/admin-api/metrics.test.js +12 -0
- package/dist/lib/routes/admin-api/metrics.test.js.map +1 -1
- package/dist/lib/routes/admin-api/project/api-token.js +7 -0
- package/dist/lib/routes/admin-api/project/api-token.js.map +1 -1
- package/dist/lib/routes/admin-api/user/user.js +5 -4
- package/dist/lib/routes/admin-api/user/user.js.map +1 -1
- package/dist/lib/routes/admin-api/user/user.test.js +30 -5
- package/dist/lib/routes/admin-api/user/user.test.js.map +1 -1
- package/dist/lib/routes/admin-api/user-admin.js +0 -1
- package/dist/lib/routes/admin-api/user-admin.js.map +1 -1
- package/dist/lib/routes/client-api/feature.js +4 -0
- package/dist/lib/routes/client-api/feature.js.map +1 -1
- package/dist/lib/routes/client-api/metrics.js +2 -0
- package/dist/lib/routes/client-api/metrics.js.map +1 -1
- package/dist/lib/routes/client-api/register.js +2 -0
- package/dist/lib/routes/client-api/register.js.map +1 -1
- package/dist/lib/routes/controller.d.ts +8 -7
- package/dist/lib/routes/controller.js +11 -10
- package/dist/lib/routes/controller.js.map +1 -1
- package/dist/lib/routes/health-check.js +2 -0
- package/dist/lib/routes/health-check.js.map +1 -1
- package/dist/lib/server-impl.js +1 -1
- package/dist/lib/server-impl.js.map +1 -1
- package/dist/lib/services/access-service.d.ts +6 -4
- package/dist/lib/services/access-service.js +47 -11
- package/dist/lib/services/access-service.js.map +1 -1
- package/dist/lib/services/access-service.test.js +39 -22
- package/dist/lib/services/access-service.test.js.map +1 -1
- package/dist/lib/services/api-token-service.d.ts +1 -0
- package/dist/lib/services/api-token-service.js +3 -0
- package/dist/lib/services/api-token-service.js.map +1 -1
- package/dist/lib/services/context-service.d.ts +4 -1
- package/dist/lib/services/context-service.js +14 -1
- package/dist/lib/services/context-service.js.map +1 -1
- package/dist/lib/services/feature-toggle-service.d.ts +1 -1
- package/dist/lib/services/feature-toggle-service.js +6 -7
- package/dist/lib/services/feature-toggle-service.js.map +1 -1
- package/dist/lib/services/group-service.js +1 -3
- package/dist/lib/services/group-service.js.map +1 -1
- package/dist/lib/services/index.d.ts +1 -1
- package/dist/lib/services/index.js +1 -1
- package/dist/lib/services/index.js.map +1 -1
- package/dist/lib/services/instance-stats-service.d.ts +2 -3
- package/dist/lib/services/project-service.js +1 -0
- package/dist/lib/services/project-service.js.map +1 -1
- package/dist/lib/services/user-service.d.ts +1 -0
- package/dist/lib/services/user-service.js +8 -0
- package/dist/lib/services/user-service.js.map +1 -1
- package/dist/lib/services/version-service.d.ts +37 -1
- package/dist/lib/services/version-service.js +76 -5
- package/dist/lib/services/version-service.js.map +1 -1
- package/dist/lib/services/version-service.test.js +196 -9
- package/dist/lib/services/version-service.test.js.map +1 -1
- package/dist/lib/types/experimental.d.ts +1 -1
- package/dist/lib/types/experimental.js +6 -2
- package/dist/lib/types/experimental.js.map +1 -1
- package/dist/lib/types/model.d.ts +9 -4
- package/dist/lib/types/model.js +1 -0
- package/dist/lib/types/model.js.map +1 -1
- package/dist/lib/types/option.d.ts +2 -0
- package/dist/lib/types/permissions.d.ts +34 -27
- package/dist/lib/types/permissions.js +85 -29
- package/dist/lib/types/permissions.js.map +1 -1
- package/dist/lib/types/services.d.ts +1 -1
- package/dist/lib/types/stores/access-store.d.ts +1 -1
- package/dist/lib/types/stores/context-field-store.d.ts +2 -0
- package/dist/lib/types/stores/environment-store.d.ts +1 -0
- package/dist/lib/types/stores/feature-strategies-store.d.ts +2 -0
- package/dist/lib/types/stores/feature-toggle-store.d.ts +1 -1
- package/dist/lib/types/stores/group-store.d.ts +1 -1
- package/dist/lib/util/constants.d.ts +7 -1
- package/dist/lib/util/constants.js +8 -2
- package/dist/lib/util/constants.js.map +1 -1
- package/dist/lib/util/ensureArray.d.ts +1 -0
- package/dist/lib/util/ensureArray.js +8 -0
- package/dist/lib/util/ensureArray.js.map +1 -0
- package/dist/lib/util/index.d.ts +1 -1
- package/dist/lib/util/index.js +1 -1
- package/dist/lib/util/index.js.map +1 -1
- package/dist/migrations/20230615122909-fix-env-sort-order.d.ts +2 -0
- package/dist/migrations/20230615122909-fix-env-sort-order.js +28 -0
- package/dist/migrations/20230615122909-fix-env-sort-order.js.map +1 -0
- package/dist/migrations/20230619105029-new-fine-grained-api-token-permissions.d.ts +2 -0
- package/dist/migrations/20230619105029-new-fine-grained-api-token-permissions.js +26 -0
- package/dist/migrations/20230619105029-new-fine-grained-api-token-permissions.js.map +1 -0
- package/dist/migrations/20230619110243-assign-apitoken-permissions-to-rootroles.d.ts +2 -0
- package/dist/migrations/20230619110243-assign-apitoken-permissions-to-rootroles.js +23 -0
- package/dist/migrations/20230619110243-assign-apitoken-permissions-to-rootroles.js.map +1 -0
- package/dist/migrations/20230621141239-refactor-api-token-permissions.d.ts +2 -0
- package/dist/migrations/20230621141239-refactor-api-token-permissions.js +19 -0
- package/dist/migrations/20230621141239-refactor-api-token-permissions.js.map +1 -0
- package/dist/server-dev.js +3 -3
- package/dist/server-dev.js.map +1 -1
- package/dist/test/arbitraries.test.js +3 -1
- package/dist/test/arbitraries.test.js.map +1 -1
- package/dist/test/config/test-config.js +0 -1
- package/dist/test/config/test-config.js.map +1 -1
- package/dist/test/e2e/api/admin/api-token.auth.e2e.test.js +542 -3
- package/dist/test/e2e/api/admin/api-token.auth.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/api-token.e2e.test.js +14 -1
- package/dist/test/e2e/api/admin/api-token.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/client-metrics.e2e.test.js +1 -8
- package/dist/test/e2e/api/admin/client-metrics.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/context.e2e.test.js +47 -1
- package/dist/test/e2e/api/admin/context.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/project/features.e2e.test.js +14 -14
- package/dist/test/e2e/api/admin/project/features.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/project/projects.e2e.test.js +14 -0
- package/dist/test/e2e/api/admin/project/projects.e2e.test.js.map +1 -1
- package/dist/test/e2e/helpers/test-helper.d.ts +1 -1
- package/dist/test/e2e/helpers/test-helper.js +4 -2
- package/dist/test/e2e/helpers/test-helper.js.map +1 -1
- package/dist/test/e2e/services/access-service.e2e.test.js +1 -1
- package/dist/test/e2e/services/access-service.e2e.test.js.map +1 -1
- package/dist/test/e2e/services/playground-service.test.js +2 -2
- package/dist/test/e2e/services/playground-service.test.js.map +1 -1
- package/dist/test/fixtures/access-service-mock.js +1 -1
- package/dist/test/fixtures/access-service-mock.js.map +1 -1
- package/dist/test/fixtures/fake-access-store.d.ts +5 -3
- package/dist/test/fixtures/fake-access-store.js +24 -9
- package/dist/test/fixtures/fake-access-store.js.map +1 -1
- package/dist/test/fixtures/fake-environment-store.d.ts +1 -0
- package/dist/test/fixtures/fake-environment-store.js +3 -0
- package/dist/test/fixtures/fake-environment-store.js.map +1 -1
- package/dist/test/fixtures/fake-feature-strategies-store.d.ts +2 -0
- package/dist/test/fixtures/fake-feature-strategies-store.js +7 -0
- package/dist/test/fixtures/fake-feature-strategies-store.js.map +1 -1
- package/dist/test/fixtures/fake-group-store.d.ts +1 -1
- package/dist/test/fixtures/fake-group-store.js +1 -1
- package/dist/test/fixtures/fake-group-store.js.map +1 -1
- package/dist/test/fixtures/fake-role-store.d.ts +1 -1
- package/dist/test/fixtures/fake-role-store.js +9 -4
- package/dist/test/fixtures/fake-role-store.js.map +1 -1
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/AdvancedPlayground-520a25e1.js +1 -0
- package/frontend/build/static/CreateProject-c430691b.js +4 -0
- package/frontend/build/static/{Error-5606eccd.js → Error-492e8b38.js} +1 -1
- package/frontend/build/static/FeatureArchiveDialog-70daa567.js +10 -0
- package/frontend/build/static/{FeatureMetricsChart-1c6bb078.js → FeatureMetricsChart-bc99b364.js} +2 -2
- package/frontend/build/static/FeatureViewLazyExport-01d70575.js +7 -0
- package/frontend/build/static/LazyAdminExport-e2c90193.js +37 -0
- package/frontend/build/static/LazyProjectExport-fa62d2fe.js +13 -0
- package/frontend/build/static/NetworkOverview-3b72e4ea.js +1298 -0
- package/frontend/build/static/NetworkTraffic-365db744.js +1 -0
- package/frontend/build/static/Playground-b473b399.js +1 -0
- package/frontend/build/static/{Playground-6602cb1a.js → PlaygroundGuidancePopper-8e3e97db.js} +12 -12
- package/frontend/build/static/RoleCell-9bb513a8.js +1 -0
- package/frontend/build/static/StrategyItemContainer-1f7503c7.js +1 -0
- package/frontend/build/static/{chartjs-adapter-date-fns.esm-c75aa905.js → chartjs-adapter-date-fns.esm-db338d44.js} +1 -1
- package/frontend/build/static/flowchart-elk-definition-170a3958-a428dd25.js +134 -0
- package/frontend/build/static/index-0a56292a.js +450 -0
- package/frontend/build/static/{index-b3def5eb.js → index-d362ae7a.js} +1 -1
- package/frontend/build/static/{index-f8439975.js → index-dc5debe9.js} +1 -1
- package/frontend/build/static/is_dark-884249e0.js +1 -0
- package/frontend/build/static/mindmap-definition-44684416-3c9425ff.js +101 -0
- package/frontend/build/static/stringify-ec884b6d.js +1 -0
- package/frontend/build/static/timeline-definition-8e5a9bc6-d289cd6d.js +62 -0
- package/frontend/build/static/{unknownify-6683037a.js → unknownify-5b23bf29.js} +1 -1
- package/frontend/package.json +18 -17
- package/package.json +16 -13
- package/dist/lib/routes/admin-api/playground.d.ts +0 -12
- package/dist/lib/routes/admin-api/playground.js +0 -46
- package/dist/lib/routes/admin-api/playground.js.map +0 -1
- package/dist/lib/routes/admin-api/playground.test.js.map +0 -1
- package/dist/lib/services/playground-service.d.ts +0 -12
- package/dist/lib/services/playground-service.js +0 -65
- package/dist/lib/services/playground-service.js.map +0 -1
- package/dist/lib/util/feature-evaluator/client.js.map +0 -1
- package/dist/lib/util/feature-evaluator/constraint.js.map +0 -1
- package/dist/lib/util/feature-evaluator/context.js.map +0 -1
- package/dist/lib/util/feature-evaluator/feature-evaluator.js.map +0 -1
- package/dist/lib/util/feature-evaluator/feature.js.map +0 -1
- package/dist/lib/util/feature-evaluator/helpers.js.map +0 -1
- package/dist/lib/util/feature-evaluator/index.js.map +0 -1
- package/dist/lib/util/feature-evaluator/repository/bootstrap-provider.js.map +0 -1
- package/dist/lib/util/feature-evaluator/repository/index.js.map +0 -1
- package/dist/lib/util/feature-evaluator/repository/storage-provider-in-mem.js.map +0 -1
- package/dist/lib/util/feature-evaluator/repository/storage-provider.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/application-hostname-strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/default-strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/flexible-rollout-strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-random.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-session-id.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/gradual-rollout-user-id.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/index.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/remote-address-strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/unknown-strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/user-with-id-strategy.js.map +0 -1
- package/dist/lib/util/feature-evaluator/strategy/util.js.map +0 -1
- package/dist/lib/util/feature-evaluator/variant.js.map +0 -1
- package/dist/lib/util/offline-unleash-client.js.map +0 -1
- package/dist/lib/util/offline-unleash-client.test.js.map +0 -1
- package/frontend/build/static/CreateProject-217f67b6.js +0 -4
- package/frontend/build/static/FeatureArchiveDialog-c311c641.js +0 -4
- package/frontend/build/static/FeatureViewLazyExport-06cf4baa.js +0 -7
- package/frontend/build/static/LazyAdminExport-04c8032d.js +0 -43
- package/frontend/build/static/LazyProjectExport-d9663a8c.js +0 -19
- package/frontend/build/static/NetworkOverview-2bce4916.js +0 -1296
- package/frontend/build/static/NetworkTraffic-7db94d86.js +0 -1
- package/frontend/build/static/StrategyItemContainer-0140b94f.js +0 -1
- package/frontend/build/static/index-1f392976.js +0 -450
- package/frontend/build/static/useProjectRole-122ac4bb.js +0 -1
- package/frontend/build/static/v4-a960c1f4.js +0 -1
- /package/dist/lib/{routes/admin-api/playground.test.d.ts → db/feature-strategy-store.test.d.ts} +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/constraint.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/constraint.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/context.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/context.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/feature-evaluator.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/feature-evaluator.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/feature.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/feature.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/helpers.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/bootstrap-provider.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/bootstrap-provider.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/index.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/index.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/storage-provider-in-mem.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/storage-provider-in-mem.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/storage-provider.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/repository/storage-provider.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/application-hostname-strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/application-hostname-strategy.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/default-strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/default-strategy.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/flexible-rollout-strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/flexible-rollout-strategy.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/gradual-rollout-random.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/gradual-rollout-random.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/gradual-rollout-session-id.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/gradual-rollout-session-id.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/gradual-rollout-user-id.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/gradual-rollout-user-id.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/index.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/index.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/remote-address-strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/remote-address-strategy.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/strategy.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/unknown-strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/user-with-id-strategy.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/user-with-id-strategy.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/util.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/strategy/util.js +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/variant.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/feature-evaluator/variant.js +0 -0
- /package/dist/lib/{util → features/playground}/offline-unleash-client.d.ts +0 -0
- /package/dist/lib/{util → features/playground}/offline-unleash-client.test.d.ts +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SdkContextSchema } from 'lib/openapi/spec/sdk-context-schema';
|
|
2
|
+
import { IUnleashServices } from 'lib/types/services';
|
|
3
|
+
import { ALL } from '../../types/models/api-token';
|
|
4
|
+
import { PlaygroundFeatureSchema } from 'lib/openapi/spec/playground-feature-schema';
|
|
5
|
+
import { IUnleashConfig } from 'lib/types';
|
|
6
|
+
import { EvaluatedPlaygroundStrategy } from 'lib/features/playground/feature-evaluator/client';
|
|
7
|
+
import { AdvancedPlaygroundFeatureSchema } from '../../openapi/spec/advanced-playground-feature-schema';
|
|
8
|
+
import { AdvancedPlaygroundEnvironmentFeatureSchema } from '../../openapi/spec/advanced-playground-environment-feature-schema';
|
|
9
|
+
import { playgroundStrategyEvaluation } from 'lib/openapi';
|
|
10
|
+
export declare type AdvancedPlaygroundEnvironmentFeatureEvaluationResult = Omit<AdvancedPlaygroundEnvironmentFeatureSchema, 'strategies'> & {
|
|
11
|
+
strategies: {
|
|
12
|
+
result: boolean | typeof playgroundStrategyEvaluation.unknownResult;
|
|
13
|
+
data: EvaluatedPlaygroundStrategy[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare type AdvancedPlaygroundFeatureEvaluationResult = Omit<AdvancedPlaygroundFeatureSchema, 'environments'> & {
|
|
17
|
+
environments: Record<string, AdvancedPlaygroundEnvironmentFeatureEvaluationResult[]>;
|
|
18
|
+
};
|
|
19
|
+
export declare type PlaygroundFeatureEvaluationResult = Omit<PlaygroundFeatureSchema, 'strategies'> & {
|
|
20
|
+
strategies: {
|
|
21
|
+
result: boolean | typeof playgroundStrategyEvaluation.unknownResult;
|
|
22
|
+
data: EvaluatedPlaygroundStrategy[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare class PlaygroundService {
|
|
26
|
+
private readonly logger;
|
|
27
|
+
private readonly featureToggleService;
|
|
28
|
+
private readonly segmentService;
|
|
29
|
+
constructor(config: IUnleashConfig, { featureToggleServiceV2, segmentService, }: Pick<IUnleashServices, 'featureToggleServiceV2' | 'segmentService'>);
|
|
30
|
+
evaluateAdvancedQuery(projects: typeof ALL | string[], environments: string[], context: SdkContextSchema, limit: number): Promise<AdvancedPlaygroundFeatureEvaluationResult[]>;
|
|
31
|
+
private evaluate;
|
|
32
|
+
private resolveFeatures;
|
|
33
|
+
evaluateQuery(projects: typeof ALL | string[], environment: string, context: SdkContextSchema): Promise<PlaygroundFeatureEvaluationResult[]>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PlaygroundService = void 0;
|
|
7
|
+
const api_token_1 = require("../../types/models/api-token");
|
|
8
|
+
const offline_unleash_client_1 = require("./offline-unleash-client");
|
|
9
|
+
const generateObjectCombinations_1 = require("./generateObjectCombinations");
|
|
10
|
+
const lodash_groupby_1 = __importDefault(require("lodash.groupby"));
|
|
11
|
+
const util_1 = require("../../util");
|
|
12
|
+
const validateQueryComplexity_1 = require("./validateQueryComplexity");
|
|
13
|
+
class PlaygroundService {
|
|
14
|
+
constructor(config, { featureToggleServiceV2, segmentService, }) {
|
|
15
|
+
this.logger = config.getLogger('services/playground-service.ts');
|
|
16
|
+
this.featureToggleService = featureToggleServiceV2;
|
|
17
|
+
this.segmentService = segmentService;
|
|
18
|
+
}
|
|
19
|
+
async evaluateAdvancedQuery(projects, environments, context, limit) {
|
|
20
|
+
const segments = await this.segmentService.getActive();
|
|
21
|
+
const environmentFeatures = await Promise.all(environments.map((env) => this.resolveFeatures(projects, env)));
|
|
22
|
+
const contexts = (0, generateObjectCombinations_1.generateObjectCombinations)(context);
|
|
23
|
+
(0, validateQueryComplexity_1.validateQueryComplexity)(environments.length, environmentFeatures[0]?.features.length ?? 0, contexts.length, limit);
|
|
24
|
+
const results = await Promise.all(environmentFeatures.flatMap(({ features, featureProject, environment }) => contexts.map((singleContext) => this.evaluate({
|
|
25
|
+
features,
|
|
26
|
+
featureProject,
|
|
27
|
+
context: singleContext,
|
|
28
|
+
segments,
|
|
29
|
+
environment,
|
|
30
|
+
}))));
|
|
31
|
+
const items = results.flat();
|
|
32
|
+
const itemsByName = (0, lodash_groupby_1.default)(items, (item) => item.name);
|
|
33
|
+
return Object.values(itemsByName).map((entries) => {
|
|
34
|
+
const groupedEnvironments = (0, lodash_groupby_1.default)(entries, (entry) => entry.environment);
|
|
35
|
+
return {
|
|
36
|
+
name: entries[0].name,
|
|
37
|
+
projectId: entries[0].projectId,
|
|
38
|
+
environments: groupedEnvironments,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async evaluate({ featureProject, features, segments, context, environment, }) {
|
|
43
|
+
const [head, ...rest] = features;
|
|
44
|
+
if (!head) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const client = await (0, offline_unleash_client_1.offlineUnleashClient)({
|
|
49
|
+
features: [head, ...rest],
|
|
50
|
+
context,
|
|
51
|
+
logError: this.logger.error,
|
|
52
|
+
segments,
|
|
53
|
+
});
|
|
54
|
+
const variantsMap = features.reduce((acc, feature) => {
|
|
55
|
+
acc[feature.name] = feature.variants;
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
const clientContext = {
|
|
59
|
+
...context,
|
|
60
|
+
currentTime: context.currentTime
|
|
61
|
+
? new Date(context.currentTime)
|
|
62
|
+
: undefined,
|
|
63
|
+
};
|
|
64
|
+
return client
|
|
65
|
+
.getFeatureToggleDefinitions()
|
|
66
|
+
.map((feature) => {
|
|
67
|
+
const strategyEvaluationResult = client.isEnabled(feature.name, clientContext);
|
|
68
|
+
const isEnabled = strategyEvaluationResult.result === true &&
|
|
69
|
+
feature.enabled;
|
|
70
|
+
return {
|
|
71
|
+
isEnabled,
|
|
72
|
+
isEnabledInCurrentEnvironment: feature.enabled,
|
|
73
|
+
strategies: {
|
|
74
|
+
result: strategyEvaluationResult.result,
|
|
75
|
+
data: strategyEvaluationResult.strategies,
|
|
76
|
+
},
|
|
77
|
+
projectId: featureProject[feature.name],
|
|
78
|
+
variant: client.getVariant(feature.name, clientContext),
|
|
79
|
+
name: feature.name,
|
|
80
|
+
environment,
|
|
81
|
+
context,
|
|
82
|
+
variants: variantsMap[feature.name] || [],
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async resolveFeatures(projects, environment) {
|
|
88
|
+
const features = await this.featureToggleService.getClientFeatures({
|
|
89
|
+
project: projects === api_token_1.ALL ? undefined : projects,
|
|
90
|
+
environment,
|
|
91
|
+
}, true, false);
|
|
92
|
+
const featureProject = features.reduce((obj, feature) => {
|
|
93
|
+
obj[feature.name] = feature.project;
|
|
94
|
+
return obj;
|
|
95
|
+
}, {});
|
|
96
|
+
return { features, featureProject, environment };
|
|
97
|
+
}
|
|
98
|
+
async evaluateQuery(projects, environment, context) {
|
|
99
|
+
const [{ features, featureProject }, segments] = await Promise.all([
|
|
100
|
+
this.resolveFeatures(projects, environment),
|
|
101
|
+
this.segmentService.getActive(),
|
|
102
|
+
]);
|
|
103
|
+
const result = await this.evaluate({
|
|
104
|
+
features,
|
|
105
|
+
featureProject,
|
|
106
|
+
segments,
|
|
107
|
+
context,
|
|
108
|
+
environment,
|
|
109
|
+
});
|
|
110
|
+
return result.map((item) => (0, util_1.omitKeys)(item, 'environment', 'context'));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.PlaygroundService = PlaygroundService;
|
|
114
|
+
//# sourceMappingURL=playground-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground-service.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/playground-service.ts"],"names":[],"mappings":";;;;;;AAGA,4DAAmD;AAInD,qEAAgE;AAQhE,6EAA0E;AAC1E,oEAAqC;AACrC,qCAAsC;AAGtC,uEAAoE;AAyCpE,MAAa,iBAAiB;IAO1B,YACI,MAAsB,EACtB,EACI,sBAAsB,EACtB,cAAc,GACoD;QAEtE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;QACjE,IAAI,CAAC,oBAAoB,GAAG,sBAAsB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,qBAAqB,CACvB,QAA+B,EAC/B,YAAsB,EACtB,OAAyB,EACzB,KAAa;QAEb,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QACvD,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,GAAG,CACzC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,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AQ;YACR,OAAO;YACP,WAAW;SACd,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,eAAQ,EAAC,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;CACJ;AA7KD,8CA6KC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AdvancedPlaygroundRequestSchema, AdvancedPlaygroundResponseSchema, PlaygroundRequestSchema, PlaygroundResponseSchema } from 'lib/openapi';
|
|
2
|
+
import { AdvancedPlaygroundFeatureEvaluationResult, PlaygroundFeatureEvaluationResult } from './playground-service';
|
|
3
|
+
export declare const advancedPlaygroundViewModel: (input: AdvancedPlaygroundRequestSchema, playgroundResult: AdvancedPlaygroundFeatureEvaluationResult[]) => AdvancedPlaygroundResponseSchema;
|
|
4
|
+
export declare const playgroundViewModel: (input: PlaygroundRequestSchema, playgroundResult: PlaygroundFeatureEvaluationResult[]) => PlaygroundResponseSchema;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.playgroundViewModel = exports.advancedPlaygroundViewModel = void 0;
|
|
4
|
+
const buildStrategyLink = (project, feature, environment, strategyId) => `/projects/${project}/features/${feature}/strategies/edit?environmentId=${environment}&strategyId=${strategyId}`;
|
|
5
|
+
const addStrategyEditLink = (environmentId, projectId, featureName, strategy) => {
|
|
6
|
+
return {
|
|
7
|
+
...strategy,
|
|
8
|
+
links: {
|
|
9
|
+
edit: buildStrategyLink(projectId, featureName, environmentId, strategy.id),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const advancedPlaygroundViewModel = (input, playgroundResult) => {
|
|
14
|
+
const features = playgroundResult.map(({ environments, ...rest }) => {
|
|
15
|
+
const transformedEnvironments = Object.entries(environments).map(([envName, envFeatures]) => {
|
|
16
|
+
const transformedFeatures = envFeatures.map(({ name, strategies, environment, projectId, ...featRest }) => ({
|
|
17
|
+
...featRest,
|
|
18
|
+
name,
|
|
19
|
+
environment,
|
|
20
|
+
projectId,
|
|
21
|
+
strategies: {
|
|
22
|
+
...strategies,
|
|
23
|
+
data: strategies.data.map((strategy) => addStrategyEditLink(environment, projectId, name, strategy)),
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
return [envName, transformedFeatures];
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
...rest,
|
|
30
|
+
environments: Object.fromEntries(transformedEnvironments),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
return { features, input };
|
|
34
|
+
};
|
|
35
|
+
exports.advancedPlaygroundViewModel = advancedPlaygroundViewModel;
|
|
36
|
+
const playgroundViewModel = (input, playgroundResult) => {
|
|
37
|
+
const features = playgroundResult.map(({ name, strategies, projectId, ...rest }) => ({
|
|
38
|
+
...rest,
|
|
39
|
+
name,
|
|
40
|
+
projectId,
|
|
41
|
+
strategies: {
|
|
42
|
+
...strategies,
|
|
43
|
+
data: strategies.data.map((strategy) => addStrategyEditLink(input.environment, projectId, name, strategy)),
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
return { input, features };
|
|
47
|
+
};
|
|
48
|
+
exports.playgroundViewModel = playgroundViewModel;
|
|
49
|
+
//# sourceMappingURL=playground-view-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground-view-model.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/playground-view-model.ts"],"names":[],"mappings":";;;AAYA,MAAM,iBAAiB,GAAG,CACtB,OAAe,EACf,OAAe,EACf,WAAmB,EACnB,UAAkB,EACZ,EAAE,CACR,aAAa,OAAO,aAAa,OAAO,kCAAkC,WAAW,eAAe,UAAU,EAAE,CAAC;AAErH,MAAM,mBAAmB,GAAG,CACxB,aAAqB,EACrB,SAAiB,EACjB,WAAmB,EACnB,QAAiD,EACzB,EAAE;IAC1B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gBAAqD,EAC7B,EAAE;IAC1B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CACjC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3C,GAAG,IAAI;QACP,IAAI;QACJ,SAAS;QACT,UAAU,EAAE;YACR,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACnC,mBAAmB,CACf,KAAK,CAAC,WAAW,EACjB,SAAS,EACT,IAAI,EACJ,QAAQ,CACX,CACJ;SACJ;KACJ,CAAC,CACL,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC;AAxBW,QAAA,mBAAmB,uBAwB9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const playground_view_model_1 = require("./playground-view-model");
|
|
4
|
+
describe('playground result to view model', () => {
|
|
5
|
+
it('adds edit links to playground models', () => {
|
|
6
|
+
const input = {
|
|
7
|
+
environment: 'development',
|
|
8
|
+
projects: '*',
|
|
9
|
+
context: { appName: 'playground', userId: '1' },
|
|
10
|
+
};
|
|
11
|
+
const featureResult = {
|
|
12
|
+
isEnabled: false,
|
|
13
|
+
isEnabledInCurrentEnvironment: false,
|
|
14
|
+
strategies: {
|
|
15
|
+
result: false,
|
|
16
|
+
data: [
|
|
17
|
+
{
|
|
18
|
+
name: 'flexibleRollout',
|
|
19
|
+
id: 'ea2c22c1-07fc-4cbe-934d-ffff57cd774b',
|
|
20
|
+
disabled: false,
|
|
21
|
+
parameters: {
|
|
22
|
+
groupId: 'test-playground',
|
|
23
|
+
rollout: '32',
|
|
24
|
+
stickiness: 'default',
|
|
25
|
+
},
|
|
26
|
+
result: {
|
|
27
|
+
enabled: false,
|
|
28
|
+
evaluationStatus: 'complete',
|
|
29
|
+
},
|
|
30
|
+
constraints: [],
|
|
31
|
+
segments: [],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
projectId: 'default',
|
|
36
|
+
variant: {
|
|
37
|
+
name: 'disabled',
|
|
38
|
+
enabled: false,
|
|
39
|
+
},
|
|
40
|
+
name: 'test-playground',
|
|
41
|
+
variants: [],
|
|
42
|
+
};
|
|
43
|
+
const viewModel = (0, playground_view_model_1.playgroundViewModel)(input, [featureResult]);
|
|
44
|
+
const transformedStrategy = viewModel.features[0].strategies.data[0];
|
|
45
|
+
// check that we're adding links correctly
|
|
46
|
+
expect(transformedStrategy).toMatchObject({
|
|
47
|
+
links: {
|
|
48
|
+
edit: expect.stringMatching(`/projects/${featureResult.projectId}/features/${featureResult.name}/strategies/edit?`) &&
|
|
49
|
+
expect.stringMatching(`environmentId=development`) &&
|
|
50
|
+
expect.stringMatching(`strategyId=${transformedStrategy.id}`),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
// check that we're not changing anything else
|
|
54
|
+
expect(viewModel).toMatchObject({ input, features: [featureResult] });
|
|
55
|
+
});
|
|
56
|
+
it('adds edit links to advanced playground models', () => {
|
|
57
|
+
const input = {
|
|
58
|
+
environments: ['development'],
|
|
59
|
+
projects: '*',
|
|
60
|
+
context: { appName: 'playground', userId: '1' },
|
|
61
|
+
};
|
|
62
|
+
const featureResult = {
|
|
63
|
+
name: 'test-playground',
|
|
64
|
+
projectId: 'default',
|
|
65
|
+
environments: {
|
|
66
|
+
development: [
|
|
67
|
+
{
|
|
68
|
+
isEnabled: false,
|
|
69
|
+
isEnabledInCurrentEnvironment: true,
|
|
70
|
+
strategies: {
|
|
71
|
+
result: false,
|
|
72
|
+
data: [
|
|
73
|
+
{
|
|
74
|
+
name: 'flexibleRollout',
|
|
75
|
+
id: '2a7dfda6-acf1-4e53-8813-6559e8bd66b0',
|
|
76
|
+
disabled: false,
|
|
77
|
+
parameters: {
|
|
78
|
+
groupId: 'test-playground',
|
|
79
|
+
rollout: '50',
|
|
80
|
+
stickiness: 'default',
|
|
81
|
+
},
|
|
82
|
+
result: {
|
|
83
|
+
enabled: false,
|
|
84
|
+
evaluationStatus: 'complete',
|
|
85
|
+
},
|
|
86
|
+
constraints: [],
|
|
87
|
+
segments: [],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
projectId: 'default',
|
|
92
|
+
variant: {
|
|
93
|
+
name: 'disabled',
|
|
94
|
+
enabled: false,
|
|
95
|
+
},
|
|
96
|
+
name: 'test-playground',
|
|
97
|
+
environment: 'development',
|
|
98
|
+
context: {
|
|
99
|
+
appName: 'playground',
|
|
100
|
+
userId: '1',
|
|
101
|
+
},
|
|
102
|
+
variants: [],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const viewModel = (0, playground_view_model_1.advancedPlaygroundViewModel)(input, [featureResult]);
|
|
108
|
+
const transformedStrategy = viewModel.features[0].environments.development[0].strategies
|
|
109
|
+
.data[0];
|
|
110
|
+
// ensure that we're adding the required data
|
|
111
|
+
expect(transformedStrategy).toMatchObject({
|
|
112
|
+
links: {
|
|
113
|
+
edit: expect.stringMatching(`/projects/${featureResult.projectId}/features/${featureResult.name}/strategies/edit?`) &&
|
|
114
|
+
expect.stringMatching(`environmentId=development`) &&
|
|
115
|
+
expect.stringMatching(`strategyId=${transformedStrategy.id}`),
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
// check that we're not changing anything else
|
|
119
|
+
expect(viewModel).toMatchObject({ input, features: [featureResult] });
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=playground-view-model.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground-view-model.test.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/playground-view-model.test.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,KAAK;yBACjB;wBACD,IAAI,EAAE,iBAAiB;wBACvB,WAAW,EAAE,aAAa;wBAC1B,OAAO,EAAE;4BACL,OAAO,EAAE,YAAY;4BACrB,MAAM,EAAE,GAAG;yBACd;wBACD,QAAQ,EAAE,EAAE;qBACf;iBACJ;aACJ;SACJ,CAAC;QAEF,MAAM,SAAS,GAAG,IAAA,mDAA2B,EAAC,KAAK,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;QACtE,MAAM,mBAAmB,GACrB,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,UAAU;aACvD,IAAI,CAAC,CAAC,CAAC,CAAC;QAEjB,6CAA6C;QAC7C,MAAM,CAAC,mBAAmB,CAAC,CAAC,aAAa,CAAC;YACtC,KAAK,EAAE;gBACH,IAAI,EACA,MAAM,CAAC,cAAc,CACjB,aAAa,aAAa,CAAC,SAAS,aAAa,aAAa,CAAC,IAAI,mBAAmB,CACzF;oBACD,MAAM,CAAC,cAAc,CAAC,2BAA2B,CAAC;oBAClD,MAAM,CAAC,cAAc,CACjB,cAAc,mBAAmB,CAAC,EAAE,EAAE,CACzC;aACR;SACJ,CAAC,CAAC;QAEH,8CAA8C;QAC9C,MAAM,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { IUnleashConfig } from '../../types/option';
|
|
3
|
+
import { IUnleashServices } from '../../types/services';
|
|
4
|
+
import Controller from '../../routes/controller';
|
|
5
|
+
import { PlaygroundResponseSchema } from '../../openapi/spec/playground-response-schema';
|
|
6
|
+
import { PlaygroundRequestSchema } from '../../openapi/spec/playground-request-schema';
|
|
7
|
+
import { AdvancedPlaygroundRequestSchema } from '../../openapi/spec/advanced-playground-request-schema';
|
|
8
|
+
import { AdvancedPlaygroundResponseSchema } from '../../openapi/spec/advanced-playground-response-schema';
|
|
9
|
+
export default class PlaygroundController extends Controller {
|
|
10
|
+
private openApiService;
|
|
11
|
+
private playgroundService;
|
|
12
|
+
private flagResolver;
|
|
13
|
+
constructor(config: IUnleashConfig, { openApiService, playgroundService, }: Pick<IUnleashServices, 'openApiService' | 'playgroundService'>);
|
|
14
|
+
evaluateContext(req: Request<any, any, PlaygroundRequestSchema>, res: Response<PlaygroundResponseSchema>): Promise<void>;
|
|
15
|
+
evaluateAdvancedContext(req: Request<any, any, AdvancedPlaygroundRequestSchema>, res: Response<AdvancedPlaygroundResponseSchema>): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const permissions_1 = require("../../types/permissions");
|
|
7
|
+
const controller_1 = __importDefault(require("../../routes/controller"));
|
|
8
|
+
const create_response_schema_1 = require("../../openapi/util/create-response-schema");
|
|
9
|
+
const endpoint_descriptions_1 = require("../../openapi/endpoint-descriptions");
|
|
10
|
+
const standard_responses_1 = require("../../openapi/util/standard-responses");
|
|
11
|
+
const create_request_schema_1 = require("../../openapi/util/create-request-schema");
|
|
12
|
+
const playground_response_schema_1 = require("../../openapi/spec/playground-response-schema");
|
|
13
|
+
const playground_view_model_1 = require("./playground-view-model");
|
|
14
|
+
class PlaygroundController extends controller_1.default {
|
|
15
|
+
constructor(config, { openApiService, playgroundService, }) {
|
|
16
|
+
super(config);
|
|
17
|
+
this.openApiService = openApiService;
|
|
18
|
+
this.playgroundService = playgroundService;
|
|
19
|
+
this.flagResolver = config.flagResolver;
|
|
20
|
+
this.route({
|
|
21
|
+
method: 'post',
|
|
22
|
+
path: '',
|
|
23
|
+
handler: this.evaluateContext,
|
|
24
|
+
permission: permissions_1.NONE,
|
|
25
|
+
middleware: [
|
|
26
|
+
openApiService.validPath({
|
|
27
|
+
operationId: 'getPlayground',
|
|
28
|
+
tags: ['Playground'],
|
|
29
|
+
responses: {
|
|
30
|
+
...(0, standard_responses_1.getStandardResponses)(400, 401),
|
|
31
|
+
200: (0, create_response_schema_1.createResponseSchema)('playgroundResponseSchema'),
|
|
32
|
+
},
|
|
33
|
+
requestBody: (0, create_request_schema_1.createRequestSchema)('playgroundRequestSchema'),
|
|
34
|
+
...endpoint_descriptions_1.endpointDescriptions.admin.playground,
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
this.route({
|
|
39
|
+
method: 'post',
|
|
40
|
+
path: '/advanced',
|
|
41
|
+
handler: this.evaluateAdvancedContext,
|
|
42
|
+
permission: permissions_1.NONE,
|
|
43
|
+
middleware: [
|
|
44
|
+
openApiService.validPath({
|
|
45
|
+
operationId: 'getAdvancedPlayground',
|
|
46
|
+
tags: ['Unstable'],
|
|
47
|
+
responses: {
|
|
48
|
+
...(0, standard_responses_1.getStandardResponses)(400, 401),
|
|
49
|
+
200: (0, create_response_schema_1.createResponseSchema)('advancedPlaygroundResponseSchema'),
|
|
50
|
+
},
|
|
51
|
+
requestBody: (0, create_request_schema_1.createRequestSchema)('advancedPlaygroundRequestSchema'),
|
|
52
|
+
...endpoint_descriptions_1.endpointDescriptions.admin.advancedPlayground,
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async evaluateContext(req, res) {
|
|
58
|
+
const result = await this.playgroundService.evaluateQuery(req.body.projects || '*', req.body.environment, req.body.context);
|
|
59
|
+
const response = (0, playground_view_model_1.playgroundViewModel)(req.body, result);
|
|
60
|
+
this.openApiService.respondWithValidation(200, res, playground_response_schema_1.playgroundResponseSchema.$id, response);
|
|
61
|
+
}
|
|
62
|
+
async evaluateAdvancedContext(req, res) {
|
|
63
|
+
if (this.flagResolver.isEnabled('advancedPlayground')) {
|
|
64
|
+
const { payload } = this.flagResolver.getVariant('advancedPlayground');
|
|
65
|
+
const limit = payload?.value && Number.isInteger(parseInt(payload?.value))
|
|
66
|
+
? parseInt(payload?.value)
|
|
67
|
+
: 15000;
|
|
68
|
+
const result = await this.playgroundService.evaluateAdvancedQuery(req.body.projects || '*', req.body.environments, req.body.context, limit);
|
|
69
|
+
const response = (0, playground_view_model_1.advancedPlaygroundViewModel)(req.body, result);
|
|
70
|
+
res.json(response);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
res.status(409).end();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = PlaygroundController;
|
|
78
|
+
//# sourceMappingURL=playground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/playground.ts"],"names":[],"mappings":";;;;;AAGA,yDAA+C;AAC/C,yEAAiD;AAEjD,sFAAiF;AACjF,+EAA2E;AAC3E,8EAA6E;AAC7E,oFAA+E;AAC/E,8FAGuD;AAMvD,mEAGiC;AAEjC,MAAqB,oBAAqB,SAAQ,oBAAU;IAOxD,YACI,MAAsB,EACtB,EACI,cAAc,EACd,iBAAiB,GAC4C;QAEjE,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QAExC,IAAI,CAAC,KAAK,CAAC;YACP,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,IAAI,CAAC,eAAe;YAC7B,UAAU,EAAE,kBAAI;YAChB,UAAU,EAAE;gBACR,cAAc,CAAC,SAAS,CAAC;o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,CAAC,qBAAqB,CACrC,GAAG,EACH,GAAG,EACH,qDAAwB,CAAC,GAAG,EAC5B,QAAQ,CACX,CAAC;IACN,CAAC;IAED,KAAK,CAAC,uBAAuB,CACzB,GAAuD,EACvD,GAA+C;QAE/C,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,oBAAoB,CAAC,EAAE;YACnD,MAAM,EAAE,OAAO,EAAE,GACb,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;YACvD,MAAM,KAAK,GACP,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACxD,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;gBAC1B,CAAC,CAAC,KAAK,CAAC;YAEhB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAC7D,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,EACxB,GAAG,CAAC,IAAI,CAAC,YAAY,EACrB,GAAG,CAAC,IAAI,CAAC,OAAO,EAChB,KAAK,CACR,CAAC;YAEF,MAAM,QAAQ,GACV,IAAA,mDAA2B,EAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAElD,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACtB;aAAM;YACH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;SACzB;IACL,CAAC;CACJ;AA/GD,uCA+GC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,14 +9,15 @@ const services_1 = require("../../services");
|
|
|
9
9
|
const test_config_1 = require("../../../test/config/test-config");
|
|
10
10
|
const store_1 = __importDefault(require("../../../test/fixtures/store"));
|
|
11
11
|
const app_1 = __importDefault(require("../../app"));
|
|
12
|
-
const playground_request_schema_1 = require("
|
|
13
|
-
const playground_request_schema_test_1 = require("
|
|
12
|
+
const playground_request_schema_1 = require("../../openapi/spec/playground-request-schema");
|
|
13
|
+
const playground_request_schema_test_1 = require("../../openapi/spec/playground-request-schema.test");
|
|
14
14
|
const arbitraries_test_1 = require("../../../test/arbitraries.test");
|
|
15
15
|
async function getSetup() {
|
|
16
16
|
const base = `/random${Math.round(Math.random() * 1000)}`;
|
|
17
17
|
const stores = (0, store_1.default)();
|
|
18
18
|
const config = (0, test_config_1.createTestConfig)({
|
|
19
19
|
server: { baseUriPath: base },
|
|
20
|
+
experimental: { flags: { strictSchemaValidation: true } },
|
|
20
21
|
});
|
|
21
22
|
const services = (0, services_1.createServices)(stores, config);
|
|
22
23
|
const app = await (0, app_1.default)(config, stores, services);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground.test.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/playground.test.ts"],"names":[],"mappings":";;;;;AAAA,4DAA4B;AAE5B,0DAAkC;AAClC,6CAAgD;AAChD,kEAAoE;AAEpE,yEAAwD;AAExD,oDAA+B;AAC/B,4FAGsD;AAEtD,sGAAgG;AAChG,qEAAgE;AAEhE,KAAK,UAAU,QAAQ;IACnB,MAAM,IAAI,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IAC1D,MAAM,MAAM,GAAG,IAAA,eAAY,GAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,IAAA,8BAAgB,EAAC;QAC5B,MAAM,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;QAC7B,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,EAAE;KAC5D,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,IAAA,yBAAc,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,MAAM,IAAA,aAAM,EAAC,MAAM,EAAE,MAAM,EAAE,Q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AAO,CAAC,CAAC;YAE1C,OAAO,IAAI,CAAC;QAChB,CAAC,CACJ,EACD,UAAU,CACb,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,uEAAuE,EAAE,KAAK,IAAI,EAAE;QACrF,MAAM,oBAAE,CAAC,MAAM,CACX,oBAAE,CAAC,aAAa,CACZ,IAAA,yCAAe,GAAE,EACjB,oBAAE,CAAC,YAAY,CAAC,GAAG,mDAAuB,CAAC,QAAQ,CAAC,EACpD,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE;YAC3B,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,EAAE,CAAC;YAE3C,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;YAE5B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO;iBAC3B,IAAI,CAAC,GAAG,IAAI,uBAAuB,CAAC;iBACpC,IAAI,CAAC,OAAO,CAAC;iBACb,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;YAEpC,OAAO,MAAM,KAAK,GAAG,CAAC;QAC1B,CAAC,CACJ,EACD,UAAU,CACb,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateQueryComplexity: (environmentsCount: number, featuresCount: number, contextCombinationsCount: number, limit?: number) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateQueryComplexity = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const MAX_COMPLEXITY = 30000;
|
|
6
|
+
const validateQueryComplexity = (environmentsCount, featuresCount, contextCombinationsCount, limit = MAX_COMPLEXITY) => {
|
|
7
|
+
const totalCount = environmentsCount * featuresCount * contextCombinationsCount;
|
|
8
|
+
const reason = `Rejecting evaluation as it would generate ${totalCount} combinations exceeding ${limit} limit. `;
|
|
9
|
+
const action = `Please reduce the number of selected environments (${environmentsCount}), features (${featuresCount}), context field combinations (${contextCombinationsCount}).`;
|
|
10
|
+
if (totalCount > limit) {
|
|
11
|
+
throw new error_1.BadDataError(reason + action);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.validateQueryComplexity = validateQueryComplexity;
|
|
15
|
+
//# sourceMappingURL=validateQueryComplexity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateQueryComplexity.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/validateQueryComplexity.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAE3C,MAAM,cAAc,GAAG,KAAK,CAAC;AAEtB,MAAM,uBAAuB,GAAG,CACnC,iBAAyB,EACzB,aAAqB,EACrB,wBAAgC,EAChC,KAAK,GAAG,cAAc,EAClB,EAAE;IACN,MAAM,UAAU,GACZ,iBAAiB,GAAG,aAAa,GAAG,wBAAwB,CAAC;IAEjE,MAAM,MAAM,GAAG,6CAA6C,UAAU,2BAA2B,KAAK,UAAU,CAAC;IACjH,MAAM,MAAM,GAAG,sDAAsD,iBAAiB,gBAAgB,aAAa,kCAAkC,wBAAwB,IAAI,CAAC;IAElL,IAAI,UAAU,GAAG,KAAK,EAAE;QACpB,MAAM,IAAI,oBAAY,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;KAC3C;AACL,CAAC,CAAC;AAfW,QAAA,uBAAuB,2BAelC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validateQueryComplexity_1 = require("./validateQueryComplexity");
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
test('should not throw error when total combinations are under MAX_COMPLEXITY', () => {
|
|
6
|
+
const environmentsCount = 10;
|
|
7
|
+
const featuresCount = 10;
|
|
8
|
+
const contextCombinationsCount = 10;
|
|
9
|
+
expect(() => (0, validateQueryComplexity_1.validateQueryComplexity)(environmentsCount, featuresCount, contextCombinationsCount)).not.toThrow();
|
|
10
|
+
});
|
|
11
|
+
test('should throw BadDataError when total combinations are over MAX_COMPLEXITY', () => {
|
|
12
|
+
const environmentsCount = 2;
|
|
13
|
+
const featuresCount = 200;
|
|
14
|
+
const contextCombinationsCount = 10000;
|
|
15
|
+
const expectedMessage = `Rejecting evaluation as it would generate 4000000 combinations exceeding 30000 limit. Please reduce the number of selected environments (2), features (200), context field combinations (10000).`;
|
|
16
|
+
expect(() => (0, validateQueryComplexity_1.validateQueryComplexity)(environmentsCount, featuresCount, contextCombinationsCount)).toThrow(error_1.BadDataError);
|
|
17
|
+
expect(() => (0, validateQueryComplexity_1.validateQueryComplexity)(environmentsCount, featuresCount, contextCombinationsCount)).toThrow(expectedMessage);
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=validateQueryComplexity.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateQueryComplexity.test.js","sourceRoot":"","sources":["../../../../src/lib/features/playground/validateQueryComplexity.test.ts"],"names":[],"mappings":";;AAAA,uEAAoE;AACpE,uCAA2C;AAE3C,IAAI,CAAC,yEAAyE,EAAE,GAAG,EAAE;IACjF,MAAM,iBAAiB,GAAG,EAAE,CAAC;IAC7B,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,MAAM,wBAAwB,GAAG,EAAE,CAAC;IAEpC,MAAM,CAAC,GAAG,EAAE,CACR,IAAA,iDAAuB,EACnB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,CAC3B,CACJ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2EAA2E,EAAE,GAAG,EAAE;IACnF,MAAM,iBAAiB,GAAG,CAAC,CAAC;IAC5B,MAAM,aAAa,GAAG,GAAG,CAAC;IAC1B,MAAM,wBAAwB,GAAG,KAAK,CAAC;IAEvC,MAAM,eAAe,GAAG,kMAAkM,CAAC;IAE3N,MAAM,CAAC,GAAG,EAAE,CACR,IAAA,iDAAuB,EACnB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,CAC3B,CACJ,CAAC,OAAO,CAAC,oBAAY,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,EAAE,CACR,IAAA,iDAAuB,EACnB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,CAC3B,CACJ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { IUnleashConfig } from '../types/option';
|
|
|
2
2
|
import { IUnleashStores } from '../types/stores';
|
|
3
3
|
import User from '../types/user';
|
|
4
4
|
interface PermissionChecker {
|
|
5
|
-
hasPermission(user: User,
|
|
5
|
+
hasPermission(user: User, permissions: string[], projectId?: string, environment?: string): Promise<boolean>;
|
|
6
6
|
}
|
|
7
7
|
declare const rbacMiddleware: (config: Pick<IUnleashConfig, 'getLogger'>, { featureToggleStore }: Pick<IUnleashStores, 'featureToggleStore'>, accessService: PermissionChecker) => any;
|
|
8
8
|
export default rbacMiddleware;
|
|
@@ -12,7 +12,10 @@ const rbacMiddleware = (config, { featureToggleStore }, accessService) => {
|
|
|
12
12
|
const logger = config.getLogger('/middleware/rbac-middleware.ts');
|
|
13
13
|
logger.debug('Enabling RBAC middleware');
|
|
14
14
|
return (req, res, next) => {
|
|
15
|
-
req.checkRbac = async (
|
|
15
|
+
req.checkRbac = async (permissions) => {
|
|
16
|
+
const permissionsArray = Array.isArray(permissions)
|
|
17
|
+
? permissions
|
|
18
|
+
: [permissions];
|
|
16
19
|
const { user, params } = req;
|
|
17
20
|
if (!user) {
|
|
18
21
|
logger.error('RBAC requires a user to exist on the request.');
|
|
@@ -31,16 +34,16 @@ const rbacMiddleware = (config, { featureToggleStore }, accessService) => {
|
|
|
31
34
|
// Temporary workaround to figure out projectId for feature toggle updates.
|
|
32
35
|
// will be removed in Unleash v5.0
|
|
33
36
|
if (!projectId &&
|
|
34
|
-
[permissions_1.DELETE_FEATURE, permissions_1.UPDATE_FEATURE].includes(permission)) {
|
|
37
|
+
permissionsArray.some((permission) => [permissions_1.DELETE_FEATURE, permissions_1.UPDATE_FEATURE].includes(permission))) {
|
|
35
38
|
const { featureName } = params;
|
|
36
39
|
projectId = await featureToggleStore.getProjectId(featureName);
|
|
37
40
|
}
|
|
38
41
|
else if (projectId === undefined &&
|
|
39
|
-
(permission == permissions_1.CREATE_FEATURE ||
|
|
42
|
+
permissionsArray.some((permission) => permission == permissions_1.CREATE_FEATURE ||
|
|
40
43
|
permission.endsWith('FEATURE_STRATEGY'))) {
|
|
41
44
|
projectId = 'default';
|
|
42
45
|
}
|
|
43
|
-
return accessService.hasPermission(user,
|
|
46
|
+
return accessService.hasPermission(user, permissionsArray, projectId, environment);
|
|
44
47
|
};
|
|
45
48
|
return next();
|
|
46
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rbac-middleware.js","sourceRoot":"","sources":["../../../src/lib/middleware/rbac-middleware.ts"],"names":[],"mappings":";;AAAA,sDAK8B;AAc9B,SAAS,SAAS,CACd,IAAY,EACZ,EAAE,MAAM,EAAE,IAAI,EAAO,EACrB,YAAqB;IAErB,IAAI,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9C,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;KACzC;IACD,OAAO,KAAK,IAAI,YAAY,CAAC;AACjC,CAAC;AAED,MAAM,cAAc,GAAG,CACnB,MAAyC,EACzC,EAAE,kBAAkB,EAA8C,EAClE,aAAgC,EAC7B,EAAE;IACL,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC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