1
1
import {
2
2
IAssignmentLogger ,
3
3
validation ,
4
- IEppoClient ,
5
4
EppoClient ,
6
5
FlagConfigurationRequestParameters ,
7
6
Flag ,
@@ -10,6 +9,9 @@ import {
10
9
ObfuscatedFlag ,
11
10
ApiEndpoints ,
12
11
applicationLogger ,
12
+ IAssignmentDetails ,
13
+ BanditActions ,
14
+ BanditSubjectAttributes ,
13
15
} from '@eppo/js-client-sdk-common' ;
14
16
15
17
import { assignmentCacheFactory } from './cache/assignment-cache-factory' ;
@@ -125,9 +127,9 @@ export interface IClientConfigSync {
125
127
126
128
// Export the common types and classes from the SDK.
127
129
export {
128
- IAssignmentLogger ,
130
+ IAssignmentDetails ,
129
131
IAssignmentEvent ,
130
- IEppoClient ,
132
+ IAssignmentLogger ,
131
133
IAsyncStore ,
132
134
Flag ,
133
135
ObfuscatedFlag ,
@@ -166,6 +168,16 @@ export class EppoJSClient extends EppoClient {
166
168
return super . getStringAssignment ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
167
169
}
168
170
171
+ public getStringAssignmentDetails (
172
+ flagKey : string ,
173
+ subjectKey : string ,
174
+ subjectAttributes : Record < string , AttributeType > ,
175
+ defaultValue : string ,
176
+ ) : IAssignmentDetails < string > {
177
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
178
+ return super . getStringAssignmentDetails ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
179
+ }
180
+
169
181
/**
170
182
* @deprecated Use getBooleanAssignment instead
171
183
*/
@@ -188,6 +200,16 @@ export class EppoJSClient extends EppoClient {
188
200
return super . getBooleanAssignment ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
189
201
}
190
202
203
+ public getBooleanAssignmentDetails (
204
+ flagKey : string ,
205
+ subjectKey : string ,
206
+ subjectAttributes : Record < string , AttributeType > ,
207
+ defaultValue : boolean ,
208
+ ) : IAssignmentDetails < boolean > {
209
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
210
+ return super . getBooleanAssignmentDetails ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
211
+ }
212
+
191
213
public getIntegerAssignment (
192
214
flagKey : string ,
193
215
subjectKey : string ,
@@ -198,6 +220,16 @@ export class EppoJSClient extends EppoClient {
198
220
return super . getIntegerAssignment ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
199
221
}
200
222
223
+ public getIntegerAssignmentDetails (
224
+ flagKey : string ,
225
+ subjectKey : string ,
226
+ subjectAttributes : Record < string , AttributeType > ,
227
+ defaultValue : number ,
228
+ ) : IAssignmentDetails < number > {
229
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
230
+ return super . getIntegerAssignmentDetails ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
231
+ }
232
+
201
233
public getNumericAssignment (
202
234
flagKey : string ,
203
235
subjectKey : string ,
@@ -208,6 +240,16 @@ export class EppoJSClient extends EppoClient {
208
240
return super . getNumericAssignment ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
209
241
}
210
242
243
+ public getNumericAssignmentDetails (
244
+ flagKey : string ,
245
+ subjectKey : string ,
246
+ subjectAttributes : Record < string , AttributeType > ,
247
+ defaultValue : number ,
248
+ ) : IAssignmentDetails < number > {
249
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
250
+ return super . getNumericAssignmentDetails ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
251
+ }
252
+
211
253
public getJSONAssignment (
212
254
flagKey : string ,
213
255
subjectKey : string ,
@@ -218,6 +260,44 @@ export class EppoJSClient extends EppoClient {
218
260
return super . getJSONAssignment ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
219
261
}
220
262
263
+ public getJSONAssignmentDetails (
264
+ flagKey : string ,
265
+ subjectKey : string ,
266
+ subjectAttributes : Record < string , AttributeType > ,
267
+ defaultValue : object ,
268
+ ) : IAssignmentDetails < object > {
269
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
270
+ return super . getJSONAssignmentDetails ( flagKey , subjectKey , subjectAttributes , defaultValue ) ;
271
+ }
272
+
273
+ public getBanditAction (
274
+ flagKey : string ,
275
+ subjectKey : string ,
276
+ subjectAttributes : BanditSubjectAttributes ,
277
+ actions : BanditActions ,
278
+ defaultValue : string ,
279
+ ) : Omit < IAssignmentDetails < string > , 'evaluationDetails' > {
280
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
281
+ return super . getBanditAction ( flagKey , subjectKey , subjectAttributes , actions , defaultValue ) ;
282
+ }
283
+
284
+ public getBanditActionDetails (
285
+ flagKey : string ,
286
+ subjectKey : string ,
287
+ subjectAttributes : BanditSubjectAttributes ,
288
+ actions : BanditActions ,
289
+ defaultValue : string ,
290
+ ) : IAssignmentDetails < string > {
291
+ EppoJSClient . getAssignmentInitializationCheck ( ) ;
292
+ return super . getBanditActionDetails (
293
+ flagKey ,
294
+ subjectKey ,
295
+ subjectAttributes ,
296
+ actions ,
297
+ defaultValue ,
298
+ ) ;
299
+ }
300
+
221
301
private static getAssignmentInitializationCheck ( ) {
222
302
if ( ! EppoJSClient . initialized ) {
223
303
applicationLogger . warn ( 'Eppo SDK assignment requested before init() completed' ) ;
@@ -242,7 +322,7 @@ export function buildStorageKeySuffix(apiKey: string): string {
242
322
* @returns a singleton client instance
243
323
* @public
244
324
*/
245
- export function offlineInit ( config : IClientConfigSync ) : IEppoClient {
325
+ export function offlineInit ( config : IClientConfigSync ) : EppoClient {
246
326
const isObfuscated = config . isObfuscated ?? false ;
247
327
const throwOnFailedInitialization = config . throwOnFailedInitialization ?? true ;
248
328
@@ -297,7 +377,7 @@ export function offlineInit(config: IClientConfigSync): IEppoClient {
297
377
* @param config - client configuration
298
378
* @public
299
379
*/
300
- export async function init ( config : IClientConfig ) : Promise < IEppoClient > {
380
+ export async function init ( config : IClientConfig ) : Promise < EppoClient > {
301
381
validation . validateNotBlank ( config . apiKey , 'API key required' ) ;
302
382
let initializationError : Error | undefined ;
303
383
const instance = EppoJSClient . instance ;
@@ -441,7 +521,7 @@ export async function init(config: IClientConfig): Promise<IEppoClient> {
441
521
* @returns a singleton client instance
442
522
* @public
443
523
*/
444
- export function getInstance ( ) : IEppoClient {
524
+ export function getInstance ( ) : EppoClient {
445
525
return EppoJSClient . instance ;
446
526
}
447
527
0 commit comments