Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/dtos/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export interface IDependencyMatcherData {

interface ISplitMatcherBase {
matcherType: string
negate: boolean
keySelector: null | {
negate?: boolean
keySelector?: null | {
trafficType: string,
attribute: string | null
attribute?: string | null
}
userDefinedSegmentMatcherData?: null | IInSegmentMatcherData
userDefinedLargeSegmentMatcherData?: null | IInLargeSegmentMatcherData
Expand Down Expand Up @@ -207,18 +207,18 @@ export interface IExcludedSegment {
export interface IRBSegment {
name: string,
changeNumber: number,
status: 'ACTIVE' | 'ARCHIVED',
conditions?: ISplitCondition[],
status?: 'ACTIVE' | 'ARCHIVED',
conditions?: ISplitCondition[] | null,
excluded?: {
keys?: string[] | null,
segments?: IExcludedSegment[] | null
}
} | null
}

export interface ISplit {
name: string,
changeNumber: number,
status: 'ACTIVE' | 'ARCHIVED',
status?: 'ACTIVE' | 'ARCHIVED',
conditions: ISplitCondition[],
prerequisites?: null | {
n: string,
Expand Down
4 changes: 2 additions & 2 deletions src/evaluator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface IMatcherDto {
name: string
value?: string | number | boolean | string[] | IDependencyMatcherData | IBetweenMatcherData | IBetweenStringMatcherData | null

attribute: string | null
negate: boolean
attribute?: string | null
negate?: boolean
dataType: string
}

Expand Down
2 changes: 1 addition & 1 deletion src/evaluator/value/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ILogger } from '../../logger/types';
import { sanitize } from './sanitize';
import { ENGINE_VALUE, ENGINE_VALUE_NO_ATTRIBUTES, ENGINE_VALUE_INVALID } from '../../logger/constants';

function parseValue(log: ILogger, key: SplitIO.SplitKey, attributeName: string | null, attributes?: SplitIO.Attributes) {
function parseValue(log: ILogger, key: SplitIO.SplitKey, attributeName?: string | null, attributes?: SplitIO.Attributes) {
let value = undefined;
if (attributeName) {
if (attributes) {
Expand Down
16 changes: 9 additions & 7 deletions src/sync/polling/updaters/splitChangesUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function checkAllSegmentsExist(segments: ISegmentsCacheBase): Promise<boolean> {
* Exported for testing purposes.
*/
export function parseSegments(ruleEntity: ISplit | IRBSegment, matcherType: typeof IN_SEGMENT | typeof IN_RULE_BASED_SEGMENT = IN_SEGMENT): Set<string> {
const { conditions = [], excluded } = ruleEntity as IRBSegment;
const { conditions, excluded } = ruleEntity as IRBSegment;

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

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

matchers.forEach(matcher => {
if (matcher.matcherType === matcherType) segments.add(matcher.userDefinedSegmentMatcherData.segmentName);
});
matchers.forEach(matcher => {
if (matcher.matcherType === matcherType) segments.add(matcher.userDefinedSegmentMatcherData.segmentName);
});
}
}

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

return rules.reduce((accum, ruleEntity) => {
if (ruleEntity.status === 'ACTIVE' && (!filters || matchFilters(ruleEntity as ISplit, filters))) {
if (ruleEntity.status !== 'ARCHIVED' && (!filters || matchFilters(ruleEntity as ISplit, filters))) {
accum.added.push(ruleEntity);

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