Skip to content

Commit e7b98c9

Browse files
authored
chore: move jsdoc to interfaces (#229)
Signed-off-by: Todd Baert <[email protected]> Signed-off-by: Todd Baert <[email protected]>
1 parent 17fa857 commit e7b98c9

File tree

3 files changed

+132
-180
lines changed

3 files changed

+132
-180
lines changed

src/client.ts

Lines changed: 1 addition & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -43,80 +43,34 @@ export class OpenFeatureClient implements Client {
4343
this._context = context;
4444
}
4545

46-
/**
47-
* Sets a logger on the client. This logger supersedes to the global logger
48-
* and is passed to various components in the SDK.
49-
*
50-
* @param {Logger} logger The logger to to be used
51-
* @returns {OpenFeatureClient} OpenFeature Client
52-
*/
5346
setLogger(logger: Logger): OpenFeatureClient {
5447
this._clientLogger = new SafeLogger(logger);
5548
return this;
5649
}
57-
58-
/**
59-
* Sets evaluation context that will be used during flag evaluations
60-
* on this client.
61-
*
62-
* @param {EvaluationContext} context Client evaluation context
63-
* @returns {OpenFeatureClient} OpenFeature Client
64-
*/
50+
6551
setContext(context: EvaluationContext): OpenFeatureClient {
6652
this._context = context;
6753
return this;
6854
}
6955

70-
/**
71-
* Access the evaluation context set on the client.
72-
*
73-
* @returns {EvaluationContext} Client evaluation context
74-
*/
7556
getContext(): EvaluationContext {
7657
return this._context;
7758
}
7859

79-
/**
80-
* Adds hooks that will run during flag evaluations on this client. Client
81-
* hooks are executed in the order they were registered. Adding additional hooks
82-
* will not remove existing hooks.
83-
*
84-
* @param {Hook<FlagValue>[]} hooks A list of hooks that should always run
85-
* @returns {OpenFeatureClient} OpenFeature Client
86-
*/
8760
addHooks(...hooks: Hook<FlagValue>[]): OpenFeatureClient {
8861
this._hooks = [...this._hooks, ...hooks];
8962
return this;
9063
}
9164

92-
/**
93-
* Access all the hooks that are registered on this client.
94-
*
95-
* @returns {Hook<FlagValue>[]} A list of the client hooks
96-
*/
9765
getHooks(): Hook<FlagValue>[] {
9866
return this._hooks;
9967
}
10068

101-
/**
102-
* Clears all the hooks that are registered on this client.
103-
*
104-
* @returns {OpenFeatureClient} OpenFeature Client
105-
*/
10669
clearHooks(): OpenFeatureClient {
10770
this._hooks = [];
10871
return this;
10972
}
11073

111-
/**
112-
* Performs a flag evaluation that returns a boolean.
113-
*
114-
* @param {string} flagKey The flag key uniquely identifies a particular flag
115-
* @param {boolean} defaultValue The value returned if an error occurs
116-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
117-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
118-
* @returns {Promise<boolean>} Flag evaluation response
119-
*/
12074
async getBooleanValue(
12175
flagKey: string,
12276
defaultValue: boolean,
@@ -126,15 +80,6 @@ export class OpenFeatureClient implements Client {
12680
return (await this.getBooleanDetails(flagKey, defaultValue, context, options)).value;
12781
}
12882

129-
/**
130-
* Performs a flag evaluation that a returns an evaluation details object.
131-
*
132-
* @param {string} flagKey The flag key uniquely identifies a particular flag
133-
* @param {boolean} defaultValue The value returned if an error occurs
134-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
135-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
136-
* @returns {Promise<EvaluationDetails<boolean>>} Flag evaluation details response
137-
*/
13883
getBooleanDetails(
13984
flagKey: string,
14085
defaultValue: boolean,
@@ -151,16 +96,6 @@ export class OpenFeatureClient implements Client {
15196
);
15297
}
15398

154-
/**
155-
* Performs a flag evaluation that returns a string.
156-
*
157-
* @param {string} flagKey The flag key uniquely identifies a particular flag
158-
* @template {string} T A optional generic argument constraining the string
159-
* @param {T} defaultValue The value returned if an error occurs
160-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
161-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
162-
* @returns {Promise<T>} Flag evaluation response
163-
*/
16499
async getStringValue<T extends string = string>(
165100
flagKey: string,
166101
defaultValue: T,
@@ -170,16 +105,6 @@ export class OpenFeatureClient implements Client {
170105
return (await this.getStringDetails<T>(flagKey, defaultValue, context, options)).value;
171106
}
172107

173-
/**
174-
* Performs a flag evaluation that a returns an evaluation details object.
175-
*
176-
* @param {string} flagKey The flag key uniquely identifies a particular flag
177-
* @template {string} T A optional generic argument constraining the string
178-
* @param {T} defaultValue The value returned if an error occurs
179-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
180-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
181-
* @returns {Promise<EvaluationDetails<T>>} Flag evaluation details response
182-
*/
183108
getStringDetails<T extends string = string>(
184109
flagKey: string,
185110
defaultValue: T,
@@ -197,16 +122,6 @@ export class OpenFeatureClient implements Client {
197122
);
198123
}
199124

200-
/**
201-
* Performs a flag evaluation that returns a number.
202-
*
203-
* @param {string} flagKey The flag key uniquely identifies a particular flag
204-
* @template {number} T A optional generic argument constraining the number
205-
* @param {T} defaultValue The value returned if an error occurs
206-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
207-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
208-
* @returns {Promise<T>} Flag evaluation response
209-
*/
210125
async getNumberValue<T extends number = number>(
211126
flagKey: string,
212127
defaultValue: T,
@@ -216,16 +131,6 @@ export class OpenFeatureClient implements Client {
216131
return (await this.getNumberDetails(flagKey, defaultValue, context, options)).value;
217132
}
218133

219-
/**
220-
* Performs a flag evaluation that a returns an evaluation details object.
221-
*
222-
* @param {string} flagKey The flag key uniquely identifies a particular flag
223-
* @template {number} T A optional generic argument constraining the number
224-
* @param {T} defaultValue The value returned if an error occurs
225-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
226-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
227-
* @returns {Promise<EvaluationDetails<T>>} Flag evaluation details response
228-
*/
229134
getNumberDetails<T extends number = number>(
230135
flagKey: string,
231136
defaultValue: T,
@@ -243,16 +148,6 @@ export class OpenFeatureClient implements Client {
243148
);
244149
}
245150

246-
/**
247-
* Performs a flag evaluation that returns an object.
248-
*
249-
* @param {string} flagKey The flag key uniquely identifies a particular flag
250-
* @template {JsonValue} T A optional generic argument describing the structure
251-
* @param {T} defaultValue The value returned if an error occurs
252-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
253-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
254-
* @returns {Promise<T>} Flag evaluation response
255-
*/
256151
async getObjectValue<T extends JsonValue = JsonValue>(
257152
flagKey: string,
258153
defaultValue: T,
@@ -262,16 +157,6 @@ export class OpenFeatureClient implements Client {
262157
return (await this.getObjectDetails(flagKey, defaultValue, context, options)).value;
263158
}
264159

265-
/**
266-
* Performs a flag evaluation that a returns an evaluation details object.
267-
*
268-
* @param {string} flagKey The flag key uniquely identifies a particular flag
269-
* @template {JsonValue} T A optional generic argument describing the structure
270-
* @param {T} defaultValue The value returned if an error occurs
271-
* @param {EvaluationContext} context The evaluation context used on an individual flag evaluation
272-
* @param {FlagEvaluationOptions} options Additional flag evaluation options
273-
* @returns {Promise<EvaluationDetails<T>>} Flag evaluation details response
274-
*/
275160
getObjectDetails<T extends JsonValue = JsonValue>(
276161
flagKey: string,
277162
defaultValue: T,

src/open-feature.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,11 @@ class OpenFeatureAPI implements GlobalApi {
2828
return instance;
2929
}
3030

31-
/**
32-
* Sets a logger that used globally within OpenFeature. This logger supersedes
33-
* to the default logger and is passed to various components in the SDK. The
34-
* global logger can be overridden per client.
35-
*
36-
* @param {Logger} logger The logger to to be used
37-
* @returns {OpenFeatureAPI} OpenFeature API
38-
*/
3931
setLogger(logger: Logger): OpenFeatureAPI {
4032
this._logger = new SafeLogger(logger);
4133
return this;
4234
}
4335

44-
/**
45-
* A factory function for creating new OpenFeature clients. Clients can contain
46-
* their own state (e.g. logger, hook, context). Multiple clients can be used
47-
* to segment feature flag configuration.
48-
*
49-
* @param {string} name The name of the client
50-
* @param {string} version The version of the client
51-
* @param {EvaluationContext} context Evaluation context that should be set on the client to used during flag evaluations
52-
* @returns {Client} OpenFeature Client
53-
*/
5436
getClient(name?: string, version?: string, context?: EvaluationContext): Client {
5537
return new OpenFeatureClient(
5638
() => this._provider,
@@ -69,68 +51,30 @@ class OpenFeatureAPI implements GlobalApi {
6951
return this._provider.metadata;
7052
}
7153

72-
/**
73-
* Adds global hooks that will always run during a flag evaluation. Global
74-
* hooks are executed in the order that they were registered. Adding additional
75-
* hooks will not remove existing hooks.
76-
*
77-
* @param {Hook<FlagValue>[]} hooks A list of hooks that should always run
78-
* @returns {OpenFeatureAPI} OpenFeature API
79-
*/
8054
addHooks(...hooks: Hook<FlagValue>[]): OpenFeatureAPI {
8155
this._hooks = [...this._hooks, ...hooks];
8256
return this;
8357
}
8458

85-
/**
86-
* Access all the hooks that are globally registered.
87-
*
88-
* @returns {Hook<FlagValue>[]} A list of the global hooks
89-
*/
9059
getHooks(): Hook<FlagValue>[] {
9160
return this._hooks;
9261
}
9362

94-
/**
95-
* Clears all the globally registered hooks.
96-
*
97-
* @returns {OpenFeatureAPI} OpenFeature API
98-
*/
9963
clearHooks(): OpenFeatureAPI {
10064
this._hooks = [];
10165
return this;
10266
}
10367

104-
/**
105-
* Sets the provider that OpenFeature will use for flag evaluations. Setting
106-
* a provider supersedes the current provider used in new and existing clients.
107-
*
108-
* @param {Provider} provider The provider responsible for flag evaluations.
109-
* @returns {OpenFeatureAPI} OpenFeature API
110-
*/
11168
setProvider(provider: Provider): OpenFeatureAPI {
11269
this._provider = provider;
11370
return this;
11471
}
11572

116-
/**
117-
* Sets a global evaluation context that will be used during all flag evaluations.
118-
* This is useful for evaluation context properties that are static (e.g. region,
119-
* environment, hostname).
120-
*
121-
* @param {EvaluationContext} context Global evaluation context
122-
* @returns {OpenFeatureAPI} OpenFeature API
123-
*/
12473
setContext(context: EvaluationContext): OpenFeatureAPI {
12574
this._context = context;
12675
return this;
12776
}
12877

129-
/**
130-
* Access the global evaluation context.
131-
*
132-
* @returns {EvaluationContext} Global evaluation context
133-
*/
13478
getContext(): EvaluationContext {
13579
return this._context;
13680
}

0 commit comments

Comments
 (0)