File tree Expand file tree Collapse file tree 3 files changed +1957
-1535
lines changed
libs/shared/flagd-core/src/lib/targeting Expand file tree Collapse file tree 3 files changed +1957
-1535
lines changed Original file line number Diff line number Diff line change 11import { flagKeyPropertyKey , flagdPropertyKey , targetingPropertyKey } from './common' ;
22import MurmurHash3 from 'imurmurhash' ;
33import type { EvaluationContext , EvaluationContextValue , Logger } from '@openfeature/core' ;
4- import { Constants } from 'json-logic-engine' ;
54
65export const fractionalRule = 'fractional' ;
76
87export function fractionalFactory ( logger : Logger ) {
9- return function fractional (
10- data : unknown ,
11- contextContainer : { [ key in typeof Constants . Override ] : EvaluationContext } ,
12- ...remaining : unknown [ ]
13- ) : string | null {
8+ return function fractional ( data : unknown , context : EvaluationContext ) : string | null {
149 if ( ! Array . isArray ( data ) ) {
1510 return null ;
1611 }
@@ -21,11 +16,7 @@ export function fractionalFactory(logger: Logger) {
2116 return null ;
2217 }
2318
24- // Extract context using JSOn Logic Engine override symbol.
25- console . log ( 'context' , contextContainer ) ;
26- console . log ( 'remaining' , remaining ) ;
27- const context = contextContainer [ Constants . Override ] ;
28- const flagdProperties = context ?. [ flagdPropertyKey ] as { [ key : string ] : EvaluationContextValue } | undefined ;
19+ const flagdProperties = context [ flagdPropertyKey ] as { [ key : string ] : EvaluationContextValue } | undefined ;
2920 if ( ! flagdProperties ) {
3021 logger . debug ( 'Missing flagd properties, cannot perform fractional targeting' ) ;
3122 return null ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export class Targeting {
1717 engine . addMethod ( startsWithRule , startsWithHandler ) ;
1818 engine . addMethod ( endsWithRule , endsWithHandler ) ;
1919 engine . addMethod ( semVerRule , semVerFactory ( logger ) ) ;
20- engine . addMethod ( fractionalRule , fractionalFactory ( logger ) , { useContext : true } ) ;
20+ engine . addMethod ( fractionalRule , fractionalFactory ( logger ) ) ;
2121
2222 // JSON logic engine returns a generic Function interface, so we cast it to any
2323 // eslint-disable-next-line @typescript-eslint/no-explicit-any
You can’t perform that action at this time.
0 commit comments