1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-26 01:17:00 +02:00

feat: now project moving is split into two events (#9358)

When project is moved, then Unleash creates only one event, which is for
target project.
We also need one for source project, to know that project was moved out
of it.

Test will be in enterprise repo.
This commit is contained in:
Jaanus Sellin 2025-02-25 12:45:24 +02:00 committed by GitHub
parent 42a05ef418
commit 55eb73cf08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,11 @@
import type {
IEventStore,
IFeatureToggleDeltaQuery,
IFeatureToggleQuery,
IFlagResolver,
ISegmentReadModel,
IUnleashConfig,
import {
FEATURE_PROJECT_CHANGE,
type IEventStore,
type IFeatureToggleDeltaQuery,
type IFeatureToggleQuery,
type IFlagResolver,
type ISegmentReadModel,
type IUnleashConfig,
} from '../../../types';
import type ConfigurationRevisionService from '../../feature-toggle/configuration-revision-service';
import { UPDATE_REVISION } from '../../feature-toggle/configuration-revision-service';
@ -238,6 +239,16 @@ export class ClientFeatureToggleDelta extends EventEmitter {
latestRevision,
);
const featuresMovedEvents = changeEvents
.filter((event) => event.featureName)
.filter((event) => event.type === FEATURE_PROJECT_CHANGE)
.map((event) => ({
eventId: latestRevision,
type: DELTA_EVENT_TYPES.FEATURE_REMOVED,
featureName: event.featureName!,
project: event.data.oldProject,
}));
const featuresUpdated = [
...new Set(
changeEvents
@ -299,6 +310,7 @@ export class ClientFeatureToggleDelta extends EventEmitter {
}),
);
this.delta[environment].addEvents([
...featuresMovedEvents,
...featuresUpdatedEvents,
...featuresRemovedEvents,
...segmentsUpdatedEvents,