UNPKG

@featurevisor/sdk

Version:

Featurevisor SDK for Node.js and the browser

37 lines (36 loc) 1.78 kB
import type { Feature, Segment, DatafileContent, SegmentKey, FeatureKey, Context, Traffic, Allocation, GroupSegment, Condition, Force } from "@featurevisor/types"; import { Logger } from "./logger"; export type GetRegex = (regexString: string, regexFlags: string) => RegExp; export interface DatafileReaderOptions { datafile: DatafileContent; logger: Logger; } export interface ForceResult { force?: Force; forceIndex?: number; } export declare class DatafileReader { private schemaVersion; private revision; private segments; private features; private logger; private regexCache; constructor(options: DatafileReaderOptions); getRevision(): string; getSchemaVersion(): string; getSegment(segmentKey: SegmentKey): Segment | undefined; getFeatureKeys(): string[]; getFeature(featureKey: FeatureKey): Feature | undefined; getVariableKeys(featureKey: FeatureKey): string[]; hasVariations(featureKey: FeatureKey): boolean; getRegex(regexString: string, regexFlags?: string): RegExp; allConditionsAreMatched(conditions: Condition[] | Condition, context: Context): boolean; segmentIsMatched(segment: Segment, context: Context): boolean; allSegmentsAreMatched(groupSegments: GroupSegment | GroupSegment[] | "*", context: Context): boolean; getMatchedTraffic(traffic: Traffic[], context: Context): Traffic | undefined; getMatchedAllocation(traffic: Traffic, bucketValue: number): Allocation | undefined; getMatchedForce(featureKey: FeatureKey | Feature, context: Context): ForceResult; parseConditionsIfStringified(conditions: Condition | Condition[]): Condition | Condition[]; parseSegmentsIfStringified(segments: GroupSegment | GroupSegment[]): GroupSegment | GroupSegment[]; }