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[]> {
|
private async segmentsForToken(): Promise<Segment[]> {
|
||||||
return mapSegmentsForClient(
|
return mapSegmentsForClient(
|
||||||
await this.services.segmentService.getAll(), // TODO coupled with enterprise feature
|
await this.services.segmentService.getAll(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,25 +281,21 @@ class FeatureToggleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
oneOf(
|
contextDefinition &&
|
||||||
|
contextDefinition.legalValues &&
|
||||||
|
contextDefinition.legalValues.length > 0
|
||||||
|
) {
|
||||||
|
const valuesToValidate = oneOf(
|
||||||
[...DATE_OPERATORS, ...SEMVER_OPERATORS, ...NUM_OPERATORS],
|
[...DATE_OPERATORS, ...SEMVER_OPERATORS, ...NUM_OPERATORS],
|
||||||
operator,
|
operator,
|
||||||
)
|
)
|
||||||
) {
|
? constraint.value
|
||||||
if (contextDefinition?.legalValues?.length > 0) {
|
: constraint.values;
|
||||||
validateLegalValues(
|
validateLegalValues(
|
||||||
contextDefinition.legalValues,
|
contextDefinition.legalValues,
|
||||||
constraint.value,
|
valuesToValidate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (contextDefinition?.legalValues?.length > 0) {
|
|
||||||
validateLegalValues(
|
|
||||||
contextDefinition.legalValues,
|
|
||||||
constraint.values,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return constraint;
|
return constraint;
|
||||||
}
|
}
|
||||||
@ -414,8 +410,8 @@ class FeatureToggleService {
|
|||||||
const newFeatureStrategy =
|
const newFeatureStrategy =
|
||||||
await this.featureStrategiesStore.createStrategyFeatureEnv({
|
await this.featureStrategiesStore.createStrategyFeatureEnv({
|
||||||
strategyName: strategyConfig.name,
|
strategyName: strategyConfig.name,
|
||||||
constraints: strategyConfig.constraints,
|
constraints: strategyConfig.constraints || [],
|
||||||
parameters: strategyConfig.parameters,
|
parameters: strategyConfig.parameters || {},
|
||||||
sortOrder: strategyConfig.sortOrder,
|
sortOrder: strategyConfig.sortOrder,
|
||||||
projectId,
|
projectId,
|
||||||
featureName,
|
featureName,
|
||||||
@ -435,7 +431,7 @@ class FeatureToggleService {
|
|||||||
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
||||||
const segments = await this.segmentService.getByStrategy(
|
const segments = await this.segmentService.getByStrategy(
|
||||||
newFeatureStrategy.id,
|
newFeatureStrategy.id,
|
||||||
); // TODO coupled with enterprise feature
|
);
|
||||||
const strategy = this.featureStrategyToPublic(
|
const strategy = this.featureStrategyToPublic(
|
||||||
newFeatureStrategy,
|
newFeatureStrategy,
|
||||||
segments,
|
segments,
|
||||||
@ -521,7 +517,7 @@ class FeatureToggleService {
|
|||||||
|
|
||||||
const segments = await this.segmentService.getByStrategy(
|
const segments = await this.segmentService.getByStrategy(
|
||||||
strategy.id,
|
strategy.id,
|
||||||
); // TODO coupled with enterprise feature
|
);
|
||||||
|
|
||||||
// Store event!
|
// Store event!
|
||||||
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
||||||
@ -567,7 +563,7 @@ class FeatureToggleService {
|
|||||||
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
||||||
const segments = await this.segmentService.getByStrategy(
|
const segments = await this.segmentService.getByStrategy(
|
||||||
strategy.id,
|
strategy.id,
|
||||||
); // TODO coupled with enterprise feature
|
);
|
||||||
const data = this.featureStrategyToPublic(strategy, segments);
|
const data = this.featureStrategyToPublic(strategy, segments);
|
||||||
const preData = this.featureStrategyToPublic(
|
const preData = this.featureStrategyToPublic(
|
||||||
existingStrategy,
|
existingStrategy,
|
||||||
@ -661,12 +657,12 @@ class FeatureToggleService {
|
|||||||
featureName,
|
featureName,
|
||||||
environment,
|
environment,
|
||||||
);
|
);
|
||||||
const result = [];
|
const result: Saved<IStrategyConfig>[] = [];
|
||||||
for (const strat of featureStrategies) {
|
for (const strat of featureStrategies) {
|
||||||
const segments =
|
const segments =
|
||||||
(await this.segmentService.getByStrategy(strat.id)).map(
|
(await this.segmentService.getByStrategy(strat.id)).map(
|
||||||
(segment) => segment.id,
|
(segment) => segment.id,
|
||||||
) ?? []; // TODO coupled with enterprise feature
|
) ?? [];
|
||||||
result.push({
|
result.push({
|
||||||
id: strat.id,
|
id: strat.id,
|
||||||
name: strat.strategyName,
|
name: strat.strategyName,
|
||||||
@ -748,7 +744,7 @@ class FeatureToggleService {
|
|||||||
includeIds?: boolean,
|
includeIds?: boolean,
|
||||||
): Promise<FeatureConfigurationClient[]> {
|
): Promise<FeatureConfigurationClient[]> {
|
||||||
const result = await this.featureToggleClientStore.getClient(
|
const result = await this.featureToggleClientStore.getClient(
|
||||||
query,
|
query || {},
|
||||||
includeIds,
|
includeIds,
|
||||||
);
|
);
|
||||||
if (this.flagResolver.isEnabled('cleanClientApi')) {
|
if (this.flagResolver.isEnabled('cleanClientApi')) {
|
||||||
@ -912,7 +908,11 @@ class FeatureToggleService {
|
|||||||
|
|
||||||
const strategyTasks = newToggle.environments.flatMap((e) =>
|
const strategyTasks = newToggle.environments.flatMap((e) =>
|
||||||
e.strategies.map((s) => {
|
e.strategies.map((s) => {
|
||||||
if (replaceGroupId && s.parameters.hasOwnProperty('groupId')) {
|
if (
|
||||||
|
replaceGroupId &&
|
||||||
|
s.parameters &&
|
||||||
|
s.parameters.hasOwnProperty('groupId')
|
||||||
|
) {
|
||||||
s.parameters.groupId = newFeatureName;
|
s.parameters.groupId = newFeatureName;
|
||||||
}
|
}
|
||||||
const context = {
|
const context = {
|
||||||
@ -986,7 +986,7 @@ class FeatureToggleService {
|
|||||||
strategyId,
|
strategyId,
|
||||||
);
|
);
|
||||||
|
|
||||||
const segments = await this.segmentService.getByStrategy(strategyId); // TODO coupled with enterprise feature
|
const segments = await this.segmentService.getByStrategy(strategyId);
|
||||||
let result: Saved<IStrategyConfig> = {
|
let result: Saved<IStrategyConfig> = {
|
||||||
id: strategy.id,
|
id: strategy.id,
|
||||||
name: strategy.strategyName,
|
name: strategy.strategyName,
|
||||||
@ -1580,7 +1580,8 @@ class FeatureToggleService {
|
|||||||
featureName,
|
featureName,
|
||||||
environment,
|
environment,
|
||||||
})
|
})
|
||||||
).variants;
|
).variants ||
|
||||||
|
[];
|
||||||
|
|
||||||
await this.eventStore.store(
|
await this.eventStore.store(
|
||||||
new EnvironmentVariantEvent({
|
new EnvironmentVariantEvent({
|
||||||
|
@ -148,7 +148,7 @@ export const createServices = (
|
|||||||
const versionService = new VersionService(stores, config);
|
const versionService = new VersionService(stores, config);
|
||||||
const healthService = new HealthService(stores, config);
|
const healthService = new HealthService(stores, config);
|
||||||
const userFeedbackService = new UserFeedbackService(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(
|
const featureToggleServiceV2 = new FeatureToggleService(
|
||||||
stores,
|
stores,
|
||||||
config,
|
config,
|
||||||
|
@ -193,7 +193,7 @@ export class InstanceStatsService {
|
|||||||
this.groupStore.count(),
|
this.groupStore.count(),
|
||||||
this.roleStore.count(),
|
this.roleStore.count(),
|
||||||
this.environmentStore.count(),
|
this.environmentStore.count(),
|
||||||
this.segmentStore.count(), // TODO coupled with enterprise feature
|
this.segmentStore.count(),
|
||||||
this.strategyStore.count(),
|
this.strategyStore.count(),
|
||||||
this.hasSAML(),
|
this.hasSAML(),
|
||||||
this.hasOIDC(),
|
this.hasOIDC(),
|
||||||
|
Loading…
Reference in New Issue
Block a user