You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@featurevisor/types

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@featurevisor/types - npm Package Compare versions

Comparing version

to
2.0.0

183

lib/index.d.ts
export type AttributeKey = string;
export type AttributeValue = string | number | boolean | Date | null | undefined;
export interface AttributeObjectValue {
[key: AttributeKey]: AttributeValue;
}
export type AttributeValue = string | number | boolean | Date | null | undefined | string[] | AttributeObjectValue;
export interface Context {
[key: AttributeKey]: AttributeValue;
}
export type AttributeType = "boolean" | "string" | "integer" | "double" | "date" | "semver";
export type AttributeType = "boolean" | "string" | "integer" | "double" | "date" | "semver" | "object" | "array";
export interface Attribute {
archived?: boolean;
key: AttributeKey;
key?: AttributeKey;
type: AttributeType;
capture?: boolean;
description?: string;
properties?: {
[key: AttributeKey]: {
type: "boolean" | "string" | "integer" | "double" | "date" | "semver" | "array";
description?: string;
};
};
}
export type Operator = "equals" | "notEquals" | "greaterThan" | "greaterThanOrEquals" | "lessThan" | "lessThanOrEquals" | "contains" | "notContains" | "startsWith" | "endsWith" | "semverEquals" | "semverNotEquals" | "semverGreaterThan" | "semverGreaterThanOrEquals" | "semverLessThan" | "semverLessThanOrEquals" | "before" | "after" | "in" | "notIn";
export type Operator = "equals" | "notEquals" | "exists" | "notExists" | "greaterThan" | "greaterThanOrEquals" | "lessThan" | "lessThanOrEquals" | "contains" | "notContains" | "startsWith" | "endsWith" | "semverEquals" | "semverNotEquals" | "semverGreaterThan" | "semverGreaterThanOrEquals" | "semverLessThan" | "semverLessThanOrEquals" | "before" | "after" | "includes" | "notIncludes" | "matches" | "notMatches" | "in" | "notIn";
export type ConditionValue = string | number | boolean | Date | null | undefined | string[];

@@ -19,3 +27,4 @@ export interface PlainCondition {

operator: Operator;
value: ConditionValue;
value?: ConditionValue;
regexFlags?: string;
}

@@ -32,8 +41,8 @@ export interface AndCondition {

export type AndOrNotCondition = AndCondition | OrCondition | NotCondition;
export type Condition = PlainCondition | AndOrNotCondition;
export type Condition = PlainCondition | AndOrNotCondition | string;
export type SegmentKey = string;
export interface Segment {
archived?: boolean;
key: SegmentKey;
conditions: Condition | Condition[] | string;
key?: SegmentKey;
conditions: Condition | Condition[];
description?: string;

@@ -66,5 +75,2 @@ }

}
export interface VariableOverrideBase {
value: VariableValue;
}
export type VariableOverrideSegmentsOrConditions = VariableOverrideSegments | VariableOverrideConditions;

@@ -76,3 +82,3 @@ export interface VariableOverride {

}
export interface Variable {
export interface VariableV1 {
key: VariableKey;

@@ -83,2 +89,8 @@ value: VariableValue;

}
export interface VariationV1 {
description?: string;
value: VariationValue;
weight?: Weight;
variables?: VariableV1[];
}
export interface Variation {

@@ -88,21 +100,19 @@ description?: string;

weight?: Weight;
variables?: Variable[];
variables?: {
[key: VariableKey]: VariableValue;
};
variableOverrides?: {
[key: VariableKey]: VariableOverride[];
};
}
export interface VariableSchema {
deprecated?: boolean;
key: VariableKey;
key?: VariableKey;
type: VariableType;
defaultValue: VariableValue;
description?: string;
useDefaultWhenDisabled?: boolean;
disabledValue?: VariableValue;
}
export type FeatureKey = string;
export interface Force {
conditions?: Condition | Condition[];
segments?: GroupSegment | GroupSegment[];
enabled?: boolean;
variation?: VariationValue;
variables?: {
[key: string]: VariableValue;
};
}
export interface Slot {

@@ -137,3 +147,6 @@ feature: FeatureKey | false;

};
allocation: Allocation[];
variationWeights?: {
[key: string]: Weight;
};
allocation?: Allocation[];
}

@@ -152,6 +165,8 @@ export type PlainBucketBy = AttributeKey;

export interface Feature {
key: FeatureKey;
key?: FeatureKey;
hash?: string;
deprecated?: boolean;
required?: Required[];
variablesSchema?: VariableSchema[] | Record<VariableKey, VariableSchema>;
variablesSchema?: Record<VariableKey, VariableSchema>;
disabledVariationValue?: VariationValue;
variations?: Variation[];

@@ -163,2 +178,14 @@ bucketBy: BucketBy;

}
export interface FeatureV1 {
key?: FeatureKey;
hash?: string;
deprecated?: boolean;
required?: Required[];
bucketBy: BucketBy;
traffic: Traffic[];
force?: Force[];
ranges?: Range[];
variablesSchema?: VariableSchema[];
variations?: VariationV1[];
}
export interface DatafileContentV1 {

@@ -169,10 +196,7 @@ schemaVersion: string;

segments: Segment[];
features: Feature[];
features: FeatureV1[];
}
export interface DatafileContentV2 {
export interface DatafileContent {
schemaVersion: string;
revision: string;
attributes: {
[key: AttributeKey]: Attribute;
};
segments: {

@@ -185,4 +209,3 @@ [key: SegmentKey]: Segment;

}
export type DatafileContent = DatafileContentV1 | DatafileContentV2;
export interface OverrideFeature {
export interface EvaluatedFeature {
enabled: boolean;

@@ -194,6 +217,6 @@ variation?: VariationValue;

}
export interface StickyFeatures {
[key: FeatureKey]: OverrideFeature;
export interface EvaluatedFeatures {
[key: FeatureKey]: EvaluatedFeature;
}
export type InitialFeatures = StickyFeatures;
export type StickyFeatures = EvaluatedFeatures;
/**

@@ -204,2 +227,3 @@ * YAML-only type

export type EnvironmentKey = string;
export type Tag = string;
export type RuleKey = string;

@@ -216,9 +240,24 @@ export interface Rule {

};
variationWeights?: {
[key: string]: Weight;
};
}
export type Tag = string;
export interface RulesByEnvironment {
[key: EnvironmentKey]: Rule[];
}
export interface Force {
conditions?: Condition | Condition[];
segments?: GroupSegment | GroupSegment[];
enabled?: boolean;
variation?: VariationValue;
variables?: {
[key: string]: VariableValue;
};
}
export interface ForceByEnvironment {
[key: EnvironmentKey]: Force[];
}
export type Expose = boolean | Tag[];
export interface Environment {
expose?: Expose;
rules: Rule[];
force?: Force[];
export interface ExposeByEnvironment {
[key: EnvironmentKey]: Expose;
}

@@ -233,10 +272,8 @@ export interface ParsedFeature {

bucketBy: BucketBy;
variablesSchema?: VariableSchema[];
disabledVariationValue?: VariationValue;
variablesSchema?: Record<VariableKey, VariableSchema>;
variations?: Variation[];
environments?: {
[key: EnvironmentKey]: Environment;
};
expose?: Expose;
rules?: Rule[];
force?: Force[];
expose?: ExposeByEnvironment | Expose;
force?: ForceByEnvironment | Force[];
rules?: RulesByEnvironment | Rule[];
}

@@ -249,2 +286,3 @@ /**

export interface ExistingFeature {
hash?: string;
variations?: {

@@ -257,3 +295,3 @@ value: VariationValue;

percentage: Percentage;
allocation: Allocation[];
allocation?: Allocation[];
}[];

@@ -274,2 +312,23 @@ ranges?: Range[];

}
export interface ExpectedEvaluations {
flag?: Record<string, any>;
variation?: Record<string, any>;
variables?: {
[key: VariableKey]: Record<string, any>;
};
}
export interface FeatureChildAssertion {
sticky?: StickyFeatures;
context?: Context;
defaultVariationValue?: VariationValue;
defaultVariableValues?: {
[key: string]: VariableValue;
};
expectedToBeEnabled?: boolean;
expectedVariation?: VariationValue;
expectedVariables?: {
[key: VariableKey]: VariableValue;
};
expectedEvaluations?: ExpectedEvaluations;
}
export interface FeatureAssertion {

@@ -279,5 +338,10 @@ matrix?: AssertionMatrix;

environment: EnvironmentKey;
at: Weight;
context: Context;
expectedToBeEnabled: boolean;
at?: Weight;
sticky?: StickyFeatures;
context?: Context;
defaultVariationValue?: VariationValue;
defaultVariableValues?: {
[key: string]: VariableValue;
};
expectedToBeEnabled?: boolean;
expectedVariation?: VariationValue;

@@ -287,4 +351,7 @@ expectedVariables?: {

};
expectedEvaluations?: ExpectedEvaluations;
children?: FeatureChildAssertion[];
}
export interface TestFeature {
key?: string;
feature: FeatureKey;

@@ -300,2 +367,3 @@ assertions: FeatureAssertion[];

export interface TestSegment {
key?: string;
segment: SegmentKey;

@@ -306,7 +374,12 @@ assertions: SegmentAssertion[];

export interface TestResultAssertionError {
type: "flag" | "variation" | "variable" | "segment";
type: "flag" | "variation" | "variable" | "segment" | "evaluation";
expected: string | number | boolean | Date | null | undefined;
actual: string | number | boolean | Date | null | undefined;
message?: string;
details?: object;
details?: {
evaluationType?: string;
evaluationKey?: string;
childIndex?: number;
[key: string]: any;
};
}

@@ -313,0 +386,0 @@ export interface TestResultAssertion {

{
"name": "@featurevisor/types",
"version": "1.35.3",
"version": "2.0.0",
"description": "Common Typescript types for Featurevisor",

@@ -43,3 +43,3 @@ "main": "dist/index.js",

"license": "MIT",
"gitHead": "253ff5dade7c9ee953f6a57cda097a6c9ed93aa2"
"gitHead": "9817e05a07735294c750ee921991509b67015afd"
}

@@ -7,10 +7,4 @@ # @featurevisor/types

## Installation
```
$ npm install --save @featurevisor/types
```
## License
MIT © [Fahad Heylaal](https://fahad19.com)
export type AttributeKey = string;
export type AttributeValue = string | number | boolean | Date | null | undefined;
export interface AttributeObjectValue {
[key: AttributeKey]: AttributeValue;
}
export type AttributeValue =
| string
| number
| boolean
| Date
| null
| undefined
| string[]
| AttributeObjectValue;
export interface Context {

@@ -9,10 +21,31 @@ [key: AttributeKey]: AttributeValue;

export type AttributeType = "boolean" | "string" | "integer" | "double" | "date" | "semver";
export type AttributeType =
| "boolean"
| "string"
| "integer"
| "double"
| "date"
| "semver"
| "object"
| "array";
export interface Attribute {
archived?: boolean; // only available in YAML files
key: AttributeKey;
key?: AttributeKey; // needed for supporting v1 datafile generation
type: AttributeType;
capture?: boolean;
description?: string; // only available in YAML files
properties?: {
[key: AttributeKey]: {
type:
| "boolean"
| "string"
| "integer"
| "double"
| "date"
| "semver"
// | "object" // NOTE: avoid nesting for now
| "array";
description?: string;
};
};
}

@@ -23,2 +56,4 @@

| "notEquals"
| "exists"
| "notExists"

@@ -50,2 +85,10 @@ // numeric

// array of strings
| "includes"
| "notIncludes"
// regex
| "matches"
| "notMatches"
// array of strings
| "in"

@@ -59,3 +102,4 @@ | "notIn";

operator: Operator;
value: ConditionValue;
value?: ConditionValue; // for all operators, except for "exists" and "notExists"
regexFlags?: string; // for regex operators only (matches, notMatches)
}

@@ -77,3 +121,3 @@

export type Condition = PlainCondition | AndOrNotCondition;
export type Condition = PlainCondition | AndOrNotCondition | string;

@@ -84,4 +128,4 @@ export type SegmentKey = string;

archived?: boolean; // only available in YAML files
key: SegmentKey;
conditions: Condition | Condition[] | string; // string only when stringified for datafile
key?: SegmentKey; // needed for supporting v1 datafile generation
conditions: Condition | Condition[]; // string only when stringified for datafile
description?: string; // only available in YAML files

@@ -140,6 +184,2 @@ }

export interface VariableOverrideBase {
value: VariableValue;
}
export type VariableOverrideSegmentsOrConditions =

@@ -149,4 +189,2 @@ | VariableOverrideSegments

// export type VariableOverride = VariableOverrideBase & VariableOverrideSegmentsOrConditions;
export interface VariableOverride {

@@ -156,3 +194,2 @@ value: VariableValue;

// one of the below must be present in YAML files
// @TODO: try with above commented out TypeScript later
conditions?: Condition | Condition[];

@@ -162,3 +199,3 @@ segments?: GroupSegment | GroupSegment[];

export interface Variable {
export interface VariableV1 {
key: VariableKey;

@@ -170,2 +207,9 @@ value: VariableValue;

export interface VariationV1 {
description?: string; // only available in YAML files
value: VariationValue;
weight?: Weight; // 0 to 100 (available from parsed YAML, but not in datafile)
variables?: VariableV1[];
}
export interface Variation {

@@ -175,3 +219,8 @@ description?: string; // only available in YAML files

weight?: Weight; // 0 to 100 (available from parsed YAML, but not in datafile)
variables?: Variable[];
variables?: {
[key: VariableKey]: VariableValue;
};
variableOverrides?: {
[key: VariableKey]: VariableOverride[];
};
}

@@ -181,6 +230,8 @@

deprecated?: boolean;
key: VariableKey;
key?: VariableKey; // @NOTE: remove
type: VariableType;
defaultValue: VariableValue;
description?: string; // only available in YAML files
useDefaultWhenDisabled?: boolean;
disabledValue?: VariableValue;
}

@@ -190,15 +241,2 @@

export interface Force {
// one of the below must be present in YAML
// @TODO: make it better with TypeScript
conditions?: Condition | Condition[];
segments?: GroupSegment | GroupSegment[];
enabled?: boolean;
variation?: VariationValue;
variables?: {
[key: string]: VariableValue;
};
}
export interface Slot {

@@ -227,3 +265,3 @@ feature: FeatureKey | false;

variation: VariationValue;
range: Range; // @TODO: in future, turn it into `ranges`, so that Allocations with same variation do not repeat
range: Range;
}

@@ -241,4 +279,7 @@

};
variationWeights?: {
[key: string]: Weight;
};
allocation: Allocation[]; // @TODO: in v2, make it optional
allocation?: Allocation[];
}

@@ -261,6 +302,8 @@

export interface Feature {
key: FeatureKey;
key?: FeatureKey; // needed for supporting v1 datafile generation
hash?: string;
deprecated?: boolean;
required?: Required[];
variablesSchema?: VariableSchema[] | Record<VariableKey, VariableSchema>;
variablesSchema?: Record<VariableKey, VariableSchema>;
disabledVariationValue?: VariationValue;
variations?: Variation[];

@@ -273,2 +316,16 @@ bucketBy: BucketBy;

export interface FeatureV1 {
key?: FeatureKey;
hash?: string;
deprecated?: boolean;
required?: Required[];
bucketBy: BucketBy;
traffic: Traffic[];
force?: Force[];
ranges?: Range[]; // if in a Group (mutex), these are the available slot ranges
variablesSchema?: VariableSchema[];
variations?: VariationV1[];
}
export interface DatafileContentV1 {

@@ -279,11 +336,8 @@ schemaVersion: string;

segments: Segment[];
features: Feature[];
features: FeatureV1[];
}
export interface DatafileContentV2 {
export interface DatafileContent {
schemaVersion: string;
revision: string;
attributes: {
[key: AttributeKey]: Attribute;
};
segments: {

@@ -297,5 +351,3 @@ [key: SegmentKey]: Segment;

export type DatafileContent = DatafileContentV1 | DatafileContentV2;
export interface OverrideFeature {
export interface EvaluatedFeature {
enabled: boolean;

@@ -308,7 +360,7 @@ variation?: VariationValue;

export interface StickyFeatures {
[key: FeatureKey]: OverrideFeature;
export interface EvaluatedFeatures {
[key: FeatureKey]: EvaluatedFeature;
}
export type InitialFeatures = StickyFeatures;
export type StickyFeatures = EvaluatedFeatures;

@@ -322,2 +374,4 @@ /**

export type Tag = string;
export type RuleKey = string;

@@ -336,12 +390,31 @@

};
variationWeights?: {
[key: string]: Weight;
};
}
export type Tag = string;
export interface RulesByEnvironment {
[key: EnvironmentKey]: Rule[];
}
export interface Force {
// one of the below must be present in YAML
conditions?: Condition | Condition[];
segments?: GroupSegment | GroupSegment[];
enabled?: boolean;
variation?: VariationValue;
variables?: {
[key: string]: VariableValue;
};
}
export interface ForceByEnvironment {
[key: EnvironmentKey]: Force[];
}
export type Expose = boolean | Tag[];
export interface Environment {
expose?: Expose;
rules: Rule[];
force?: Force[];
export interface ExposeByEnvironment {
[key: EnvironmentKey]: Expose;
}

@@ -362,14 +435,10 @@

variablesSchema?: VariableSchema[];
disabledVariationValue?: VariationValue;
variablesSchema?: Record<VariableKey, VariableSchema>;
variations?: Variation[];
// if using environments
environments?: {
[key: EnvironmentKey]: Environment;
};
// if not using environments
expose?: Expose;
rules?: Rule[];
force?: Force[];
expose?: ExposeByEnvironment | Expose;
force?: ForceByEnvironment | Force[];
rules?: RulesByEnvironment | Rule[];
}

@@ -383,4 +452,4 @@

export interface ExistingFeature {
hash?: string;
variations?: {
// @TODO: use Exclude with Variation?
value: VariationValue;

@@ -390,6 +459,5 @@ weight: Weight;

traffic: {
// @TODO: use Exclude with Traffic?
key: RuleKey;
percentage: Percentage;
allocation: Allocation[]; // @TODO: in v2, make it optional
allocation?: Allocation[];
}[];

@@ -414,2 +482,27 @@ ranges?: Range[]; // if in a Group (mutex), these are the available slot ranges

export interface ExpectedEvaluations {
flag?: Record<string, any>;
variation?: Record<string, any>;
variables?: {
[key: VariableKey]: Record<string, any>;
};
}
export interface FeatureChildAssertion {
sticky?: StickyFeatures;
context?: Context;
defaultVariationValue?: VariationValue;
defaultVariableValues?: {
[key: string]: VariableValue;
};
expectedToBeEnabled?: boolean;
expectedVariation?: VariationValue;
expectedVariables?: {
[key: VariableKey]: VariableValue;
};
expectedEvaluations?: ExpectedEvaluations;
}
export interface FeatureAssertion {

@@ -419,5 +512,13 @@ matrix?: AssertionMatrix;

environment: EnvironmentKey;
at: Weight; // bucket weight: 0 to 100
context: Context;
expectedToBeEnabled: boolean;
at?: Weight; // bucket weight: 0 to 100
sticky?: StickyFeatures;
context?: Context;
defaultVariationValue?: VariationValue;
defaultVariableValues?: {
[key: string]: VariableValue;
};
expectedToBeEnabled?: boolean;
expectedVariation?: VariationValue;

@@ -427,5 +528,9 @@ expectedVariables?: {

};
expectedEvaluations?: ExpectedEvaluations;
children?: FeatureChildAssertion[];
}
export interface TestFeature {
key?: string; // file path
feature: FeatureKey;

@@ -443,2 +548,3 @@ assertions: FeatureAssertion[];

export interface TestSegment {
key?: string; // file path
segment: SegmentKey;

@@ -451,7 +557,12 @@ assertions: SegmentAssertion[];

export interface TestResultAssertionError {
type: "flag" | "variation" | "variable" | "segment";
type: "flag" | "variation" | "variable" | "segment" | "evaluation";
expected: string | number | boolean | Date | null | undefined;
actual: string | number | boolean | Date | null | undefined;
message?: string;
details?: object;
details?: {
evaluationType?: string; // e.g., "flag", "variation", "variable"
evaluationKey?: string; // e.g., "myFeatureKey", "myVariableKey"
childIndex?: number; // for children assertions
[key: string]: any;
};
}

@@ -458,0 +569,0 @@

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.