@@ -104,11 +104,12 @@ export interface Features {
104104}
105105
106106/**
107- * Function which transforms the EvaluationContext to a type useful for the provider.
107+ * Interface that providers must implement to resolve flag values for their particular
108+ * backend or vendor.
109+ *
110+ * Implementation for resolving all the required flag types must be defined.
108111 */
109- export type ContextTransformer < T = unknown > = ( context : EvaluationContext ) => T ;
110-
111- interface GenericProvider < T > {
112+ export interface Provider extends Pick < Partial < EvaluationLifeCycle > , 'hooks' > {
112113 readonly metadata : ProviderMetadata ;
113114
114115 /**
@@ -117,7 +118,7 @@ interface GenericProvider<T> {
117118 resolveBooleanEvaluation (
118119 flagKey : string ,
119120 defaultValue : boolean ,
120- transformedContext : T ,
121+ context : EvaluationContext ,
121122 options : FlagEvaluationOptions | undefined
122123 ) : Promise < ResolutionDetails < boolean > > ;
123124
@@ -127,7 +128,7 @@ interface GenericProvider<T> {
127128 resolveStringEvaluation (
128129 flagKey : string ,
129130 defaultValue : string ,
130- transformedContext : T ,
131+ context : EvaluationContext ,
131132 options : FlagEvaluationOptions | undefined
132133 ) : Promise < ResolutionDetails < string > > ;
133134
@@ -137,7 +138,7 @@ interface GenericProvider<T> {
137138 resolveNumberEvaluation (
138139 flagKey : string ,
139140 defaultValue : number ,
140- transformedContext : T ,
141+ context : EvaluationContext ,
141142 options : FlagEvaluationOptions | undefined
142143 ) : Promise < ResolutionDetails < number > > ;
143144
@@ -147,40 +148,17 @@ interface GenericProvider<T> {
147148 resolveObjectEvaluation < U extends object > (
148149 flagKey : string ,
149150 defaultValue : U ,
150- transformedContext : T ,
151+ context : EvaluationContext ,
151152 options : FlagEvaluationOptions | undefined
152153 ) : Promise < ResolutionDetails < U > > ;
153154}
154155
155- export type NonTransformingProvider = GenericProvider < EvaluationContext > ;
156-
157- export interface TransformingProvider < T > extends GenericProvider < T > {
158- contextTransformer : ContextTransformer < Promise < T > | T > | undefined ;
159- }
160-
161- /**
162- * Interface that providers must implement to resolve flag values for their particular
163- * backend or vendor.
164- *
165- * Implementation for resolving all the required flag types must be defined.
166- *
167- * Additionally, a ContextTransformer function that transforms the OpenFeature context to the requisite user/context/attribute representation (typeof T)
168- * may also be implemented. This function will run immediately before the flag value resolver functions, appropriately transforming the context.
169- */
170- export type Provider < T extends EvaluationContext | unknown = EvaluationContext > = T extends EvaluationContext
171- ? NonTransformingProvider
172- : TransformingProvider < T > ;
173-
174156export interface EvaluationLifeCycle {
175157 addHooks ( ...hooks : Hook [ ] ) : void ;
176158 get hooks ( ) : Hook [ ] ;
177159 clearHooks ( ) : void ;
178160}
179161
180- export interface ProviderOptions < T = unknown > {
181- contextTransformer ?: ContextTransformer < T > ;
182- }
183-
184162export enum StandardResolutionReasons {
185163 /**
186164 * Indicates that the feature flag is targeting
@@ -204,20 +182,20 @@ export enum StandardResolutionReasons {
204182 * similar functions in the Client */
205183 DEFAULT = 'DEFAULT' ,
206184 /**
207- * Indicates that the feature flag evaluated to a
185+ * Indicates that the feature flag evaluated to a
208186 * static value, for example, the default value for the flag
209- *
187+ *
210188 * Note: Typically means that no dynamic evaluation has been
211189 * executed for the feature flag
212190 */
213- STATIC = 'STATIC' ,
191+ STATIC = 'STATIC' ,
214192 /**
215193 * Indicates an unknown issue occurred during evaluation
216194 */
217195 UNKNOWN = 'UNKNOWN' ,
218196 /**
219197 * Indicates that an error occurred during evaluation
220- *
198+ *
221199 * Note: The `errorCode`-field contains the details of this error
222200 */
223201 ERROR = 'ERROR' ,
0 commit comments