@@ -15,28 +15,28 @@ import { from, Observable } from 'rxjs';
1515 */
1616interface FeatureClientProps {
1717 /**
18- * The name of the OpenFeature client, if a named client should be used.
18+ * The domain of the OpenFeature client, if a domain scoped client should be used.
1919 * @see {@link Client.getBooleanDetails }
2020 */
21- name ?: string ;
21+ domain ?: string ;
2222}
2323
2424/**
2525 * Injects a feature client into a constructor or property of a class.
2626 * @param {FeatureClientProps } [props] The options for injecting the client.
2727 * @returns {PropertyDecorator & ParameterDecorator } The decorator function.
2828 */
29- export const FeatureClient = ( props ?: FeatureClientProps ) => Inject ( getOpenFeatureClientToken ( props ?. name ) ) ;
29+ export const FeatureClient = ( props ?: FeatureClientProps ) => Inject ( getOpenFeatureClientToken ( props ?. domain ) ) ;
3030
3131/**
3232 * Options for injecting a feature flag into a route handler.
3333 */
3434interface FeatureProps < T extends FlagValue > {
3535 /**
36- * The name of the OpenFeature client, if a named client should be used.
36+ * The domain of the OpenFeature client, if a domain scoped client should be used.
3737 * @see {@link OpenFeature#getClient }
3838 */
39- clientName ?: string ;
39+ domain ?: string ;
4040 /**
4141 * The key of the feature flag.
4242 * @see {@link Client#getBooleanDetails }
@@ -55,19 +55,19 @@ interface FeatureProps<T extends FlagValue> {
5555}
5656
5757/**
58- * Returns a named or unnamed OpenFeature client with the given context.
59- * @param {string } clientName The name of the OpenFeature client.
58+ * Returns a domain scoped or the default OpenFeature client with the given context.
59+ * @param {string } clientDomain The domain of the OpenFeature client.
6060 * @param {EvaluationContext } context The evaluation context of the client.
6161 * @returns {Client } The OpenFeature client.
6262 */
63- function getClientForEvaluation ( clientName ?: string , context ?: EvaluationContext ) {
64- return clientName ? OpenFeature . getClient ( clientName , context ) : OpenFeature . getClient ( context ) ;
63+ function getClientForEvaluation ( domain ?: string , context ?: EvaluationContext ) {
64+ return domain ? OpenFeature . getClient ( domain , context ) : OpenFeature . getClient ( context ) ;
6565}
6666
6767/**
6868 * Route handler parameter decorator.
6969 *
70- * Gets the {@link EvaluationDetails} for given feature flag from a named or unnamed OpenFeature
70+ * Gets the {@link EvaluationDetails} for given feature flag from a domain scoped or the default OpenFeature
7171 * client and populates the annotated parameter with the {@link EvaluationDetails} wrapped in an {@link Observable}.
7272 *
7373 * For example:
@@ -82,16 +82,16 @@ function getClientForEvaluation(clientName?: string, context?: EvaluationContext
8282 * @returns {ParameterDecorator }
8383 */
8484export const BooleanFeatureFlag = createParamDecorator (
85- ( { clientName , flagKey, defaultValue, context } : FeatureProps < boolean > ) : Observable < EvaluationDetails < boolean > > => {
86- const client = getClientForEvaluation ( clientName , context ) ;
85+ ( { domain , flagKey, defaultValue, context } : FeatureProps < boolean > ) : Observable < EvaluationDetails < boolean > > => {
86+ const client = getClientForEvaluation ( domain , context ) ;
8787 return from ( client . getBooleanDetails ( flagKey , defaultValue ) ) ;
8888 } ,
8989) ;
9090
9191/**
9292 * Route handler parameter decorator.
9393 *
94- * Gets the {@link EvaluationDetails} for given feature flag from a named or unnamed OpenFeature
94+ * Gets the {@link EvaluationDetails} for given feature flag from a domain scoped or the default OpenFeature
9595 * client and populates the annotated parameter with the {@link EvaluationDetails} wrapped in an {@link Observable}.
9696 *
9797 * For example:
@@ -106,16 +106,16 @@ export const BooleanFeatureFlag = createParamDecorator(
106106 * @returns {ParameterDecorator }
107107 */
108108export const StringFeatureFlag = createParamDecorator (
109- ( { clientName , flagKey, defaultValue, context } : FeatureProps < string > ) : Observable < EvaluationDetails < string > > => {
110- const client = getClientForEvaluation ( clientName , context ) ;
109+ ( { domain , flagKey, defaultValue, context } : FeatureProps < string > ) : Observable < EvaluationDetails < string > > => {
110+ const client = getClientForEvaluation ( domain , context ) ;
111111 return from ( client . getStringDetails ( flagKey , defaultValue ) ) ;
112112 } ,
113113) ;
114114
115115/**
116116 * Route handler parameter decorator.
117117 *
118- * Gets the {@link EvaluationDetails} for given feature flag from a named or unnamed OpenFeature
118+ * Gets the {@link EvaluationDetails} for given feature flag from a domain scoped or the default OpenFeature
119119 * client and populates the annotated parameter with the {@link EvaluationDetails} wrapped in an {@link Observable}.
120120 *
121121 * For example:
@@ -130,16 +130,16 @@ export const StringFeatureFlag = createParamDecorator(
130130 * @returns {ParameterDecorator }
131131 */
132132export const NumberFeatureFlag = createParamDecorator (
133- ( { clientName , flagKey, defaultValue, context } : FeatureProps < number > ) : Observable < EvaluationDetails < number > > => {
134- const client = getClientForEvaluation ( clientName , context ) ;
133+ ( { domain , flagKey, defaultValue, context } : FeatureProps < number > ) : Observable < EvaluationDetails < number > > => {
134+ const client = getClientForEvaluation ( domain , context ) ;
135135 return from ( client . getNumberDetails ( flagKey , defaultValue ) ) ;
136136 } ,
137137) ;
138138
139139/**
140140 * Route handler parameter decorator.
141141 *
142- * Gets the {@link EvaluationDetails} for given feature flag from a named or unnamed OpenFeature
142+ * Gets the {@link EvaluationDetails} for given feature flag from a domain scoped or the default OpenFeature
143143 * client and populates the annotated parameter with the {@link EvaluationDetails} wrapped in an {@link Observable}.
144144 *
145145 * For example:
@@ -154,13 +154,8 @@ export const NumberFeatureFlag = createParamDecorator(
154154 * @returns {ParameterDecorator }
155155 */
156156export const ObjectFeatureFlag = createParamDecorator (
157- ( {
158- clientName,
159- flagKey,
160- defaultValue,
161- context,
162- } : FeatureProps < JsonValue > ) : Observable < EvaluationDetails < JsonValue > > => {
163- const client = getClientForEvaluation ( clientName , context ) ;
157+ ( { domain, flagKey, defaultValue, context } : FeatureProps < JsonValue > ) : Observable < EvaluationDetails < JsonValue > > => {
158+ const client = getClientForEvaluation ( domain , context ) ;
164159 return from ( client . getObjectDetails ( flagKey , defaultValue ) ) ;
165160 } ,
166161) ;
0 commit comments