Skip to content

Commit 5775b5e

Browse files
committed
Adjus types.d.ts, bump to 3.4.1
1 parent 8803db1 commit 5775b5e

File tree

5 files changed

+106
-59
lines changed

5 files changed

+106
-59
lines changed

examples/nextjs/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flagsmith-es/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flagsmith-es",
3-
"version": "3.4.0",
3+
"version": "3.4.1",
44
"description": "Feature flagging to support continuous development. This is an esm equivalent of the standard flagsmith npm module.",
55
"main": "./index.js",
66
"type": "module",

flagsmith/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flagsmith",
3-
"version": "3.4.0",
3+
"version": "3.4.1",
44
"description": "Feature flagging to support continuous development",
55
"main": "./index.js",
66
"repository": {

react-native-flagsmith/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-flagsmith",
3-
"version": "3.4.0",
3+
"version": "3.4.1",
44
"description": "Feature flagging to support continuous development",
55
"main": "./index.js",
66
"repository": {

types.d.ts

Lines changed: 96 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,149 @@
1-
export interface IBulletTrainFeature {
2-
enabled: boolean;
3-
value?: string | number | boolean;
1+
export interface IFlagsmithFeature {
2+
enabled: boolean
3+
value?: string|number|boolean
44
}
5-
export interface IFlagsmithFeature extends IBulletTrainFeature {
6-
}
7-
export declare type IFlagsmithTrait = string | number | boolean;
5+
6+
export type IFlagsmithTrait = string|number|boolean
7+
8+
/*
9+
example: {hero:{enabled:true, value:"blue"}, myCoolFeature:{enabled:true}}
10+
* */
811
export interface IFlags {
9-
[key: string]: IFlagsmithFeature;
12+
[key: string]: IFlagsmithFeature
1013
}
14+
15+
/*
16+
example: {favourite_color: "blue", age: 21}
17+
* */
1118
export interface ITraits {
12-
[key: string]: IFlagsmithTrait;
13-
}
14-
export interface IUserIdentity {
15-
flags: IFlagsmithFeature;
16-
traits: ITraits;
19+
[key: string]: IFlagsmithTrait
1720
}
21+
1822
export interface IRetrieveInfo {
19-
isFromServer: boolean;
20-
flagsChanged: boolean;
21-
traitsChanged: boolean;
23+
isFromServer: boolean
24+
flagsChanged: boolean
25+
traitsChanged: boolean
2226
}
2327
export interface IState {
24-
api: string;
25-
environmentID: string;
26-
flags?: IFlags;
27-
identity?: string;
28-
traits: ITraits;
28+
api: string
29+
environmentID: string
30+
flags?: IFlags
31+
identity?: string
32+
traits: ITraits
33+
}
34+
type ICacheOptions = {
35+
ttl?:number, // how long to persist the cache in ms (defaults to 0 which is infinite)
36+
/*
37+
If this is true and there's cache available, it will skip hitting the API as if preventFetch was true
38+
Note: this is just for flagsmith.init(), Calls to identify, getFlags etc will still hit the API regardless
39+
*/
40+
skipAPI?:boolean
41+
}
42+
export interface IInitConfig {
43+
AsyncStorage?: any // an AsyncStorage implementation
44+
api?: string // the api you wish to use, important if self hosting
45+
cacheFlags?: boolean // whether to local storage flags, needs AsyncStorage defined
46+
cacheOptions?: ICacheOptions // A ttl in ms (default to 0 which is infinite) and option to skip hitting the API in flagsmith.init if there's cache available.
47+
defaultFlags?: IFlags //
48+
enableAnalytics?: boolean // Enable sending flag analytics for getValue and hasFeature evaluations.
49+
enableDynatrace?: boolean // Enables the Dynatrace RUM integration
50+
enableLogs?: boolean // whether to enable logs
51+
angularHttpClient?: any // an angular http client to support ssr
52+
environmentID: string // your Flagsmith environment id
53+
headers?: object // pass custom headers for flagsmith api calls
54+
identity?: string // Initialise with a given identity
55+
traits?: ITraits // Initialise with a given set of traits
56+
onChange?: (previousFlags:IFlags, params:IRetrieveInfo)=> void // triggered when the flags are retrieved
57+
onError?: (res:{message:string}) => void // triggered if there was an api error
58+
preventFetch?: boolean // whether to prevent fetching flags on init
59+
state?: IState // set a predefined state, useful for isomorphic applications
60+
_trigger?: ()=>void // Used internally, this function will callback separately to onChange whenever flags are updated
2961
}
3062
export interface IFlagsmith {
3163
/**
3264
* Initialise the sdk against a particular environment
3365
*/
34-
init: (config: {
35-
environmentID: string;
36-
api?: string;
37-
headers?: object;
38-
AsyncStorage?: any;
39-
cacheFlags?: boolean;
40-
preventFetch?: boolean;
41-
enableAnalytics?: boolean;
42-
enableLogs?: boolean;
43-
onChange?: (previousFlags: IFlags, params: IRetrieveInfo) => void;
44-
state?: IState;
45-
onError?: (res: {
46-
message: string;
47-
}) => void;
48-
defaultFlags?: IFlags;
49-
}) => Promise<void>;
66+
init:(config: IInitConfig) => Promise<void>
67+
5068
/**
5169
* Trigger a manual fetch of the environment features
5270
*/
53-
getFlags: () => Promise<null>;
71+
getFlags:()=> Promise<null>
72+
5473
/**
5574
* Returns the current flags
5675
*/
57-
getAllFlags: () => IFlags;
76+
getAllFlags:()=> IFlags
77+
5878
/**
5979
* Identify user, triggers a call to get flags if flagsmith.init has been called
6080
*/
61-
identify: (userId: string, traits?: Record<string, string | number | boolean>) => Promise<void>;
81+
identify:(userId:string, traits?: Record<string, string|number|boolean>,) => Promise<void>
82+
6283
/**
6384
* Retrieves the current state of flagsmith
6485
*/
65-
getState: () => IState;
86+
getState:()=> IState
87+
6688
/**
6789
* Clears the identity, triggers a call to getFlags
6890
*/
69-
logout: () => Promise<null>;
91+
logout:()=> Promise<null>
92+
7093
/**
7194
* Polls the flagsmith API, specify interval in ms
7295
*/
73-
startListening: (interval?: number) => void;
96+
startListening:(interval?:number)=> void
97+
7498
/**
7599
* Stops polling
76100
*/
77-
stopListening: () => void;
101+
stopListening:()=> void
102+
78103
/**
79104
* Get the whether a flag is enabled e.g. flagsmith.hasFeature("powerUserFeature")
80105
*/
81-
hasFeature: (key: string) => boolean;
106+
hasFeature:(key: string)=> boolean
107+
82108
/**
83109
* Get the value of a particular remote config e.g. flagsmith.getValue("font_size")
84110
*/
85-
getValue: (key: string) => string | number | boolean;
111+
getValue:(key: string) => string|number|boolean
112+
86113
/**
87114
* Get the value of a particular trait for the identified user
88115
*/
89-
getTrait: (key: string) => string | number | boolean;
116+
getTrait:(key: string) => string|number|boolean
117+
90118
/**
91119
* Set a specific trait for a given user id, triggers a call to get flags
92120
*/
93-
setTrait: (key: string, value: string | number | boolean) => Promise<null>;
121+
setTrait:(
122+
key: string,
123+
value: string|number|boolean
124+
)=> Promise<null>
125+
94126
/**
95127
* Set a key value set of traits for a given user, triggers a call to get flags
96128
*/
97-
setTraits: (traits: Record<string, string | number | boolean>) => Promise<null>;
129+
setTraits:(
130+
traits: Record<string, string|number|boolean>,
131+
)=> Promise<null>
132+
98133
/**
99134
* The stored identity of the user
100135
*/
101-
identity?: string;
136+
identity?:string
137+
138+
/**
139+
* Whether the flagsmith SDK is initialised
140+
*/
141+
initialised?:boolean
142+
143+
/**
144+
* Used internally, this function will callback separately to onChange whenever flags are updated
145+
*/
146+
trigger?:()=>{}
147+
148+
cacheOptions: { ttl: number, skipAPI: boolean }
102149
}

0 commit comments

Comments
 (0)