mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: fix compilation issues in features service (#3323)
## About the changes This PR fixes a bunch of null check errors: https://github.com/Unleash/unleash/actions/runs/4509279284/jobs/7938853559#step:5:39
This commit is contained in:
parent
d4b4866552
commit
3f29fa5ec8
@ -139,7 +139,7 @@ export class ProxyRepository
|
||||
|
||||
private async segmentsForToken(): Promise<Segment[]> {
|
||||
return mapSegmentsForClient(
|
||||
await this.services.segmentService.getAll(), // TODO coupled with enterprise feature
|
||||
await this.services.segmentService.getAll(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -281,24 +281,20 @@ class FeatureToggleService {
|
||||
}
|
||||
|
||||
if (
|
||||
oneOf(
|
||||
contextDefinition &&
|
||||
contextDefinition.legalValues &&
|
||||
contextDefinition.legalValues.length > 0
|
||||
) {
|
||||
const valuesToValidate = oneOf(
|
||||
[...DATE_OPERATORS, ...SEMVER_OPERATORS, ...NUM_OPERATORS],
|
||||
operator,
|
||||
)
|
||||
) {
|
||||
if (contextDefinition?.legalValues?.length > 0) {
|
||||
validateLegalValues(
|
||||
contextDefinition.legalValues,
|
||||
constraint.value,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (contextDefinition?.legalValues?.length > 0) {
|
||||
validateLegalValues(
|
||||
contextDefinition.legalValues,
|
||||
constraint.values,
|
||||
);
|
||||
}
|
||||
? constraint.value
|
||||
: constraint.values;
|
||||
validateLegalValues(
|
||||
contextDefinition.legalValues,
|
||||
valuesToValidate,
|
||||
);
|
||||
}
|
||||
|
||||
return constraint;
|
||||
@ -414,8 +410,8 @@ class FeatureToggleService {
|
||||
const newFeatureStrategy =
|
||||
await this.featureStrategiesStore.createStrategyFeatureEnv({
|
||||
strategyName: strategyConfig.name,
|
||||
constraints: strategyConfig.constraints,
|
||||
parameters: strategyConfig.parameters,
|
||||
constraints: strategyConfig.constraints || [],
|
||||
parameters: strategyConfig.parameters || {},
|
||||
sortOrder: strategyConfig.sortOrder,
|
||||
projectId,
|
||||
featureName,
|
||||
@ -435,7 +431,7 @@ class FeatureToggleService {
|
||||
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
||||
const segments = await this.segmentService.getByStrategy(
|
||||
newFeatureStrategy.id,
|
||||
); // TODO coupled with enterprise feature
|
||||
);
|
||||
const strategy = this.featureStrategyToPublic(
|
||||
newFeatureStrategy,
|
||||
segments,
|
||||
@ -521,7 +517,7 @@ class FeatureToggleService {
|
||||
|
||||
const segments = await this.segmentService.getByStrategy(
|
||||
strategy.id,
|
||||
); // TODO coupled with enterprise feature
|
||||
);
|
||||
|
||||
// Store event!
|
||||
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
||||
@ -567,7 +563,7 @@ class FeatureToggleService {
|
||||
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
||||
const segments = await this.segmentService.getByStrategy(
|
||||
strategy.id,
|
||||
); // TODO coupled with enterprise feature
|
||||
);
|
||||
const data = this.featureStrategyToPublic(strategy, segments);
|
||||
const preData = this.featureStrategyToPublic(
|
||||
existingStrategy,
|
||||
@ -661,12 +657,12 @@ class FeatureToggleService {
|
||||
featureName,
|
||||
environment,
|
||||
);
|
||||
const result = [];
|
||||
const result: Saved<IStrategyConfig>[] = [];
|
||||
for (const strat of featureStrategies) {
|
||||
const segments =
|
||||
(await this.segmentService.getByStrategy(strat.id)).map(
|
||||
(segment) => segment.id,
|
||||
) ?? []; // TODO coupled with enterprise feature
|
||||
) ?? [];
|
||||
result.push({
|
||||
id: strat.id,
|
||||
name: strat.strategyName,
|
||||
@ -748,7 +744,7 @@ class FeatureToggleService {
|
||||
includeIds?: boolean,
|
||||
): Promise<FeatureConfigurationClient[]> {
|
||||
const result = await this.featureToggleClientStore.getClient(
|
||||
query,
|
||||
query || {},
|
||||
includeIds,
|
||||
);
|
||||
if (this.flagResolver.isEnabled('cleanClientApi')) {
|
||||
@ -912,7 +908,11 @@ class FeatureToggleService {
|
||||
|
||||
const strategyTasks = newToggle.environments.flatMap((e) =>
|
||||
e.strategies.map((s) => {
|
||||
if (replaceGroupId && s.parameters.hasOwnProperty('groupId')) {
|
||||
if (
|
||||
replaceGroupId &&
|
||||
s.parameters &&
|
||||
s.parameters.hasOwnProperty('groupId')
|
||||
) {
|
||||
s.parameters.groupId = newFeatureName;
|
||||
}
|
||||
const context = {
|
||||
@ -986,7 +986,7 @@ class FeatureToggleService {
|
||||
strategyId,
|
||||
);
|
||||
|
||||
const segments = await this.segmentService.getByStrategy(strategyId); // TODO coupled with enterprise feature
|
||||
const segments = await this.segmentService.getByStrategy(strategyId);
|
||||
let result: Saved<IStrategyConfig> = {
|
||||
id: strategy.id,
|
||||
name: strategy.strategyName,
|
||||
@ -1580,7 +1580,8 @@ class FeatureToggleService {
|
||||
featureName,
|
||||
environment,
|
||||
})
|
||||
).variants;
|
||||
).variants ||
|
||||
[];
|
||||
|
||||
await this.eventStore.store(
|
||||
new EnvironmentVariantEvent({
|
||||
|
@ -148,7 +148,7 @@ export const createServices = (
|
||||
const versionService = new VersionService(stores, config);
|
||||
const healthService = new HealthService(stores, config);
|
||||
const userFeedbackService = new UserFeedbackService(stores, config);
|
||||
const segmentService = new SegmentService(stores, config); // TODO coupled with enterprise feature
|
||||
const segmentService = new SegmentService(stores, config);
|
||||
const featureToggleServiceV2 = new FeatureToggleService(
|
||||
stores,
|
||||
config,
|
||||
|
@ -193,7 +193,7 @@ export class InstanceStatsService {
|
||||
this.groupStore.count(),
|
||||
this.roleStore.count(),
|
||||
this.environmentStore.count(),
|
||||
this.segmentStore.count(), // TODO coupled with enterprise feature
|
||||
this.segmentStore.count(),
|
||||
this.strategyStore.count(),
|
||||
this.hasSAML(),
|
||||
this.hasOIDC(),
|
||||
|
Loading…
Reference in New Issue
Block a user