1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
This commit is contained in:
Jaanus 2025-09-01 15:51:30 +03:00
parent 8ee9fa5574
commit 91d93cb247
No known key found for this signature in database

View File

@ -8,8 +8,10 @@ import {
FeatureCompletedEvent, FeatureCompletedEvent,
FeatureUncompletedEvent, FeatureUncompletedEvent,
type IAuditUser, type IAuditUser,
type IEnvironment,
type IEnvironmentStore, type IEnvironmentStore,
type IEventStore, type IEventStore,
type IFeatureEnvironment,
type IFeatureEnvironmentStore, type IFeatureEnvironmentStore,
type IFlagResolver, type IFlagResolver,
type IUnleashConfig, type IUnleashConfig,
@ -209,7 +211,7 @@ export class FeatureLifecycleService {
return {environments, allFeatures}; return {environments, allFeatures};
} }
private async buildEnvironmentMap() { private async buildEnvironmentMap(): Promise<Map<string, IEnvironment>> {
const allEnvs = await this.environmentStore.getAll(); const allEnvs = await this.environmentStore.getAll();
return new Map(allEnvs.map((env) => [env.name, env])); return new Map(allEnvs.map((env) => [env.name, env]));
} }
@ -217,7 +219,10 @@ export class FeatureLifecycleService {
private async buildFeatureEnvironmentMap(allFeatures: string[]) { private async buildFeatureEnvironmentMap(allFeatures: string[]) {
const allFeatureEnvs = const allFeatureEnvs =
await this.featureEnvironmentStore.getAllByFeatures(allFeatures); await this.featureEnvironmentStore.getAllByFeatures(allFeatures);
const featureEnvMap = new Map<string, Map<string, any>>(); const featureEnvMap = new Map<
string,
Map<string, IFeatureEnvironment>
>();
allFeatureEnvs.forEach((fe) => { allFeatureEnvs.forEach((fe) => {
if (!featureEnvMap.has(fe.environment)) { if (!featureEnvMap.has(fe.environment)) {
@ -232,8 +237,8 @@ export class FeatureLifecycleService {
private determineLifecycleStages( private determineLifecycleStages(
events: IClientMetricsEnv[], events: IClientMetricsEnv[],
environments: string[], environments: string[],
envMap: Map<string, any>, envMap: Map<string, IEnvironment>,
featureEnvMap: Map<string, Map<string, any>>, featureEnvMap: Map<string, Map<string, IFeatureEnvironment>>,
): Array<{ feature: string; stage: 'pre-live' | 'live' }> { ): Array<{ feature: string; stage: 'pre-live' | 'live' }> {
const allStagesToInsert: Array<{ const allStagesToInsert: Array<{
feature: string; feature: string;
@ -292,7 +297,7 @@ export class FeatureLifecycleService {
private getEnabledFeaturesForEnvironment( private getEnabledFeaturesForEnvironment(
features: string[], features: string[],
environment: string, environment: string,
featureEnvMap: Map<string, Map<string, any>>, featureEnvMap: Map<string, Map<string, IFeatureEnvironment>>,
): string[] { ): string[] {
const envFeatureEnvs = featureEnvMap.get(environment) || new Map(); const envFeatureEnvs = featureEnvMap.get(environment) || new Map();
return features.filter((feature) => { return features.filter((feature) => {