Skip to content

Commit

Permalink
fix: match variant and feature types with unleash openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Jan 11, 2024
1 parent cb6b89a commit d051df2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class UnleashClient extends EventEmitter {
feature.strategies?.some((strategySelector): boolean => {
const strategy = this.getStrategy(strategySelector.name);
if (!strategy) {
this.warnStrategyOnce(strategySelector.name, feature.name, feature.strategies);
this.warnStrategyOnce(strategySelector.name, feature.name, feature.strategies || []);
return false;
}
const constraints = this.yieldConstraintsFor(strategySelector);
Expand Down
12 changes: 6 additions & 6 deletions src/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export interface Dependency {

export interface FeatureInterface {
name: string;
type: string;
project: string;
type?: string;
project?: string;
description?: string;
enabled: boolean;
stale: boolean;
impressionData: boolean;
strategies: StrategyTransportInterface[];
variants: VariantDefinition[];
stale?: boolean;
impressionData?: boolean;
strategies?: StrategyTransportInterface[];
variants?: VariantDefinition[];
dependencies?: Dependency[];
}

Expand Down
5 changes: 3 additions & 2 deletions src/variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum PayloadType {
STRING = 'string',
JSON = 'json',
CSV = 'csv',
NUMBER = 'number',
}

interface Override {
Expand All @@ -24,7 +25,7 @@ export interface VariantDefinition {
name: string;
weight: number;
stickiness?: string;
payload: Payload;
payload?: Payload;
overrides?: Override[];
}

Expand Down Expand Up @@ -131,5 +132,5 @@ export function selectVariant(
feature: FeatureInterface,
context: Context,
): VariantDefinition | null {
return selectVariantDefinition(feature.name, feature.variants, context);
return selectVariantDefinition(feature.name, feature.variants || [], context);
}

0 comments on commit d051df2

Please sign in to comment.