-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathmodel.ts
86 lines (75 loc) · 2.69 KB
/
model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* eslint-disable @typescript-eslint/no-explicit-any */
import { FlagValue, ErrorCode, EvaluationContextValue } from '@openfeature/web-sdk';
/**
* GoFeatureFlagEvaluationContext is the representation of a user for GO Feature Flag
* the key is used to do the repartition in GO Feature Flag this is the only
* mandatory field when calling the API.
*/
export interface GoFeatureFlagEvaluationContext {
key: string;
custom?: {
[key: string]: EvaluationContextValue;
};
}
/**
* GoFeatureFlagAllFlagRequest is the request format used to call the GO Feature Flag
* API to retrieve all the feature flags for this user.
*/
export interface GoFeatureFlagAllFlagRequest {
evaluationContext: GoFeatureFlagEvaluationContext;
}
/**
* GoFeatureFlagProviderOptions is the object containing all the provider options
* when initializing the open-feature provider.
*/
export interface GoFeatureFlagWebProviderOptions {
// endpoint is the URL where your GO Feature Flag server is located.
endpoint: string;
// timeout is the time in millisecond we wait for an answer from the server.
apiTimeout?: number;
// apiKey (optional) If the relay proxy is configured to authenticate the requests, you should provide
// an API Key to the provider. Please ask the administrator of the relay proxy to provide an API Key.
// (This feature is available only if you are using GO Feature Flag relay proxy v1.7.0 or above)
// Default: null
apiKey?: string;
// initial delay in millisecond to wait before retrying to connect to GO Feature Flag (websocket and API)
// Default: 100 ms
retryInitialDelay?: number;
// multiplier of retryInitialDelay after each failure
// (example: 1st connection retry will be after 100ms, second after 200ms, third after 400ms ...)
// Default: 2
retryDelayMultiplier?: number;
// maximum number of retries before considering GO Feature Flag is unreachable
// Default: 10
maxRetries?: number;
}
/**
* FlagState is the object used to get the value return by GO Feature Flag.
*/
export interface FlagState<T extends FlagValue> {
failed: boolean;
trackEvents: boolean;
value: T;
variationType: string;
version?: string;
reason: string;
metadata: Record<string, string | number | boolean>;
errorCode?: ErrorCode;
cacheable: boolean;
}
/**
* GOFeatureFlagAllFlagsResponse is the object containing the results returned
* by GO Feature Flag.
*/
export interface GOFeatureFlagAllFlagsResponse {
valid: boolean;
flags: Record<string, FlagState<FlagValue>>;
}
/**
* Format of the websocket event we can receive.
*/
export interface GOFeatureFlagWebsocketResponse {
deleted?: { [key: string]: any };
added?: { [key: string]: any };
updated?: { [key: string]: any };
}