Skip to content

Commit 880727f

Browse files
Merge pull request #477 from splitio/polishing
Polishing
2 parents 9fc9461 + dbf6978 commit 880727f

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/dtos/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export interface IDependencyMatcherData {
4141

4242
interface ISplitMatcherBase {
4343
matcherType: string
44-
negate: boolean
45-
keySelector: null | {
44+
negate?: boolean
45+
keySelector?: null | {
4646
trafficType: string,
47-
attribute: string | null
47+
attribute?: string | null
4848
}
4949
userDefinedSegmentMatcherData?: null | IInSegmentMatcherData
5050
userDefinedLargeSegmentMatcherData?: null | IInLargeSegmentMatcherData
@@ -207,18 +207,18 @@ export interface IExcludedSegment {
207207
export interface IRBSegment {
208208
name: string,
209209
changeNumber: number,
210-
status: 'ACTIVE' | 'ARCHIVED',
211-
conditions?: ISplitCondition[],
210+
status?: 'ACTIVE' | 'ARCHIVED',
211+
conditions?: ISplitCondition[] | null,
212212
excluded?: {
213213
keys?: string[] | null,
214214
segments?: IExcludedSegment[] | null
215-
}
215+
} | null
216216
}
217217

218218
export interface ISplit {
219219
name: string,
220220
changeNumber: number,
221-
status: 'ACTIVE' | 'ARCHIVED',
221+
status?: 'ACTIVE' | 'ARCHIVED',
222222
conditions: ISplitCondition[],
223223
prerequisites?: null | {
224224
n: string,

src/evaluator/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export interface IMatcherDto {
1313
name: string
1414
value?: string | number | boolean | string[] | IDependencyMatcherData | IBetweenMatcherData | IBetweenStringMatcherData | null
1515

16-
attribute: string | null
17-
negate: boolean
16+
attribute?: string | null
17+
negate?: boolean
1818
dataType: string
1919
}
2020

src/evaluator/value/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ILogger } from '../../logger/types';
44
import { sanitize } from './sanitize';
55
import { ENGINE_VALUE, ENGINE_VALUE_NO_ATTRIBUTES, ENGINE_VALUE_INVALID } from '../../logger/constants';
66

7-
function parseValue(log: ILogger, key: SplitIO.SplitKey, attributeName: string | null, attributes?: SplitIO.Attributes) {
7+
function parseValue(log: ILogger, key: SplitIO.SplitKey, attributeName?: string | null, attributes?: SplitIO.Attributes) {
88
let value = undefined;
99
if (attributeName) {
1010
if (attributes) {

src/sync/polling/updaters/splitChangesUpdater.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function checkAllSegmentsExist(segments: ISegmentsCacheBase): Promise<boolean> {
3131
* Exported for testing purposes.
3232
*/
3333
export function parseSegments(ruleEntity: ISplit | IRBSegment, matcherType: typeof IN_SEGMENT | typeof IN_RULE_BASED_SEGMENT = IN_SEGMENT): Set<string> {
34-
const { conditions = [], excluded } = ruleEntity as IRBSegment;
34+
const { conditions, excluded } = ruleEntity as IRBSegment;
3535

3636
const segments = new Set<string>();
3737
if (excluded && excluded.segments) {
@@ -42,12 +42,14 @@ export function parseSegments(ruleEntity: ISplit | IRBSegment, matcherType: type
4242
});
4343
}
4444

45-
for (let i = 0; i < conditions.length; i++) {
46-
const matchers = conditions[i].matcherGroup.matchers;
45+
if (conditions) {
46+
for (let i = 0; i < conditions.length; i++) {
47+
const matchers = conditions[i].matcherGroup.matchers;
4748

48-
matchers.forEach(matcher => {
49-
if (matcher.matcherType === matcherType) segments.add(matcher.userDefinedSegmentMatcherData.segmentName);
50-
});
49+
matchers.forEach(matcher => {
50+
if (matcher.matcherType === matcherType) segments.add(matcher.userDefinedSegmentMatcherData.segmentName);
51+
});
52+
}
5153
}
5254

5355
return segments;
@@ -88,7 +90,7 @@ function matchFilters(featureFlag: ISplit, filters: ISplitFiltersValidation) {
8890
export function computeMutation<T extends ISplit | IRBSegment>(rules: Array<T>, segments: Set<string>, filters?: ISplitFiltersValidation): ISplitMutations<T> {
8991

9092
return rules.reduce((accum, ruleEntity) => {
91-
if (ruleEntity.status === 'ACTIVE' && (!filters || matchFilters(ruleEntity as ISplit, filters))) {
93+
if (ruleEntity.status !== 'ARCHIVED' && (!filters || matchFilters(ruleEntity as ISplit, filters))) {
9294
accum.added.push(ruleEntity);
9395

9496
parseSegments(ruleEntity).forEach((segmentName: string) => {

0 commit comments

Comments
 (0)