From ab81528536750749f19c8ce67040b7e3040bb676 Mon Sep 17 00:00:00 2001 From: Fredrik Strand Oseberg Date: Tue, 1 Oct 2024 11:56:26 +0200 Subject: [PATCH] feat: add transactional support for access service (#8311) Continuing splitting #8271 into smaller pieces. This PR adds transactional support for access service. --- src/lib/services/index.ts | 8 ++++++++ src/lib/types/services.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/lib/services/index.ts b/src/lib/services/index.ts index 9c6ef7845e72..c0c6fa78a944 100644 --- a/src/lib/services/index.ts +++ b/src/lib/services/index.ts @@ -63,8 +63,10 @@ import { } from '../features/change-request-segment-usage-service/createChangeRequestSegmentUsageReadModel'; import ConfigurationRevisionService from '../features/feature-toggle/configuration-revision-service'; import { + createAccessService, createEnvironmentService, createEventsService, + createFakeAccessService, createFakeEnvironmentService, createFakeEventsService, createFakeProjectService, @@ -165,6 +167,11 @@ export const createServices = ( ? createEventsService(db, config) : createFakeEventsService(config, stores); const groupService = new GroupService(stores, config, eventService); + + const transactionalAccessService = db + ? withTransactional((db) => createAccessService(db, config), db) + : withFakeTransactional(createFakeAccessService(config).accessService); + const accessService = new AccessService( stores, config, @@ -411,6 +418,7 @@ export const createServices = ( : createFakePersonalDashboardService(config); return { + transactionalAccessService, accessService, accountService, addonService, diff --git a/src/lib/types/services.ts b/src/lib/types/services.ts index f84ca20e8f1b..626553f6c1ce 100644 --- a/src/lib/types/services.ts +++ b/src/lib/types/services.ts @@ -59,6 +59,7 @@ import type { OnboardingService } from '../features/onboarding/onboarding-servic import type { PersonalDashboardService } from '../features/personal-dashboard/personal-dashboard-service'; export interface IUnleashServices { + transactionalAccessService: WithTransactional; accessService: AccessService; accountService: AccountService; addonService: AddonService;