@eppo/node-server-sdk
Advanced tools
Comparing version 1.0.1 to 1.0.2
import ExperimentConfigurationRequestor from './experiment/experiment-configuration-requestor'; | ||
import { AttributeValueType } from './rule'; | ||
/** | ||
@@ -18,3 +17,3 @@ * Client for assigning experiment variations. | ||
*/ | ||
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: Record<string, AttributeValueType>): string; | ||
getAssignment(subjectKey: string, experimentKey: string, subjectAttributes?: Record<string, any>): string; | ||
} | ||
@@ -21,0 +20,0 @@ export default class EppoClient implements IEppoClient { |
@@ -28,2 +28,3 @@ "use strict"; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
subjectAttributesSatisfyRules(subjectAttributes, rules) { | ||
@@ -30,0 +31,0 @@ if (!rules || rules.length === 0) { |
@@ -18,3 +18,2 @@ import { IEppoClient } from './eppo-client'; | ||
export { IEppoClient } from './eppo-client'; | ||
export { AttributeValueType } from './rule'; | ||
/** | ||
@@ -21,0 +20,0 @@ * Initializes the Eppo client with configuration parameters. |
@@ -1,3 +0,3 @@ | ||
import { Rule, AttributeValueType } from './rule'; | ||
export declare function matchesAnyRule(subjectAttributes: Record<string, AttributeValueType>, rules: Rule[]): boolean; | ||
import { Rule } from './rule'; | ||
export declare function matchesAnyRule(subjectAttributes: Record<string, any>, rules: Rule[]): boolean; | ||
//# sourceMappingURL=rule_evaluator.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matchesAnyRule = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
const rule_1 = require("./rule"); | ||
@@ -23,3 +24,3 @@ function matchesAnyRule(subjectAttributes, rules) { | ||
const value = subjectAttributes[condition.attribute]; | ||
if (value) { | ||
if (value != null) { | ||
switch (condition.operator) { | ||
@@ -36,2 +37,6 @@ case rule_1.OperatorType.GTE: | ||
return new RegExp(condition.value).test(value); | ||
case rule_1.OperatorType.ONE_OF: | ||
return isOneOf(value, condition.value); | ||
case rule_1.OperatorType.NOT_ONE_OF: | ||
return isNotOneOf(value, condition.value); | ||
} | ||
@@ -41,2 +46,8 @@ } | ||
} | ||
function isOneOf(attributeValue, conditionValue) { | ||
return conditionValue.includes(attributeValue.toString()); | ||
} | ||
function isNotOneOf(attributeValue, conditionValue) { | ||
return !conditionValue.includes(attributeValue.toString()); | ||
} | ||
function compareNumber(attributeValue, conditionValue, compareFn) { | ||
@@ -43,0 +54,0 @@ return (typeof attributeValue === 'number' && |
@@ -1,2 +0,1 @@ | ||
export declare type AttributeValueType = string | number; | ||
export declare enum OperatorType { | ||
@@ -7,3 +6,5 @@ MATCHES = "MATCHES", | ||
LTE = "LTE", | ||
LT = "LT" | ||
LT = "LT", | ||
ONE_OF = "ONE_OF", | ||
NOT_ONE_OF = "NOT_ONE_OF" | ||
} | ||
@@ -13,3 +14,3 @@ export interface Condition { | ||
attribute: string; | ||
value: AttributeValueType; | ||
value: any; | ||
} | ||
@@ -16,0 +17,0 @@ export interface Rule { |
@@ -11,3 +11,5 @@ "use strict"; | ||
OperatorType["LT"] = "LT"; | ||
OperatorType["ONE_OF"] = "ONE_OF"; | ||
OperatorType["NOT_ONE_OF"] = "NOT_ONE_OF"; | ||
})(OperatorType = exports.OperatorType || (exports.OperatorType = {})); | ||
//# sourceMappingURL=rule.js.map |
{ | ||
"name": "@eppo/node-server-sdk", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Eppo node server SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40679
59
506